Skip to main content

Pdf-file generator

Project description

Pdf_gen guide

Installing

pip3 install pdf_gen

How to use

from pdf_gen.pdf_gen import pdf

my_file = pdf(path, name) # path - path to your file, name - name of file
my_file.random_drawing(count) # count - count of drawings
my_file.next_page() # turns the page
my_file.set_font(size) # size - size of font
data = {
            'title': 'Table title',
            'columns': [
                {'name': 'X_name', 'value': 'x'},
                {'name': 'Y_name', 'value': 'y'}
            ],
            'rows': [
                {'x': 10, 'y': 20},
                {'x': 5, 'y': 10}
            ]
}
my_file.draw_table(data, x, y) # data - dict with data
#  x and y - coordinates of left-bottom corner of table
my_file.write_text(text, position, x, y) # text - string of text to writing, position - left/mid/right position 
#  of string of text, x and y - coordinates of string
my_file.insert_image(path, x, y, width, height) # path - path to image,
#  x and y - coordinates of left-bottom corner of image
# width and height - sizes of image
my_file.save(author, title) # author - author of file, title - title of file

Example

from pdf_gen.pdf_gen import pdf

file = pdf('c:/projects/pdf_generator/tests', 'compare')
file.write_text('Testing file', 'right', 350, 800)
file.next_page()
data = {
            'title': 'Table title',
            'columns': [
                {'name': 'Name', 'value': 'name'},
                {'name': 'Age', 'value': 'age'}
            ],
            'rows': [
                {'name': 'string1', 'age': 23},
                {'name': 'string2', 'age': 43}
            ]
        }
file.draw_table(data)
file.next_page()
file.random_drawing(10)
file.save() 

You can create some pdf and merge it into one

from pdf_gen.pdf_gen import pdf, merge_pdf

file_names = ['first', 'second', 'third', 'fourth']
paths = []
for file_name in file_names:
    page = pdf('/files/', f'{file_name}.pdf')
    paths.append(f'/files/{file_name}.pdf')
    page.write_text(file_name)
    page.random_drawing(10)
    page.save()
merge_pdf(paths, '/files/res.pdf', True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdf_gen-0.0.7.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdf_gen-0.0.7-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file pdf_gen-0.0.7.tar.gz.

File metadata

  • Download URL: pdf_gen-0.0.7.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for pdf_gen-0.0.7.tar.gz
Algorithm Hash digest
SHA256 f3330566ca0bd3bc159672c615af3231aa951cfff9ef29ff81fad4202629045b
MD5 84e6f2ce6364184ef0f1a8549a884008
BLAKE2b-256 37a56f4ab599a331545154afc2513e1fc0e80ef96d509efd219607f76dd33ac6

See more details on using hashes here.

File details

Details for the file pdf_gen-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: pdf_gen-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

File hashes

Hashes for pdf_gen-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 cb94d8e8e4d254c5a8fb2a231c969d095a692d063f5ba1e9ec86bb361e8d1d04
MD5 507650cec0955be79537faa4e282c34b
BLAKE2b-256 1ca97bea4e83402b3d169eb977d9de689cf4ac2a18d3d1cc15ec85fef7be1047

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page