carol_pdf_generator is a Python library for creating PDF Files from images (png, jpg) file. Base64 encoded is also supported.
Installation
Use the package manager pip to install foobar.
pip install carol_pdf_generator
Usage
from carol_pdf_generator import get_from_file_list, get_from_base64_list
from urllib import request
file_list = [
'jpgfile.jpg',
'pngfile.png'
]
base64_images.append(request.urlopen('https://pastebin.com/raw/k3VZeNHW').read().decode('latin1'))
base64_images.append(request.urlopen('https://pastebin.com/raw/CaZJ7n6s').read().decode('latin1'))
base64_images.append(request.urlopen('https://pastebin.com/raw/7Asb2iMJ').read().decode('latin1'))
from_file = get_from_file_list(file_list)
base64 = get_from_base64_list(base64_images, 'test.pdf') # Returns the PDF base64 encoded data uri and saves the PDF to test.pdf
Document Scan and auto rotation
This library can automatic try to identify paper documents and rotate the image to better fits the PDF Document.
base64_jpg = str(DataURI.make(
mimetype='image/jpeg',
charset='latin1',
base64=True,
data=request.urlopen('https://raw.githubusercontent.com/danielgatis/docscan/master/examples/doc-1.jpg').read().decode('latin-1')
))
base64_png_2 = str(DataURI.make(
mimetype='image/png',
charset='latin1',
base64=True,
data=request.urlopen('https://raw.githubusercontent.com/danielgatis/docscan/master/examples/doc-2.png').read().decode('latin-1')
))
base64_jpg_3 = str(DataURI.make(
mimetype='image/jpeg',
charset='latin1',
base64=True,
data=request.urlopen('https://raw.githubusercontent.com/danielgatis/docscan/master/examples/doc-3.jpg').read().decode('latin-1')
))
base64_images = [
base64_jpg,
base64_png_2,
base64_jpg_3
]
# Returns the PDF base64 encoded data uri and saves the PDF to test.pdf, correcting the document geometry and auto rotating the images
pdf = get_from_base64_list(base64_images, auto_rotate=True, scan_docs=True, output_file="test.pdf")
Merging PDF and images
This library you can create a PDF file merging PDF, JPEG and PNG files. Just use merge_pdfs() function using a List() of base64 encoded files as parameter.
from carol_pdf_generator.carol_pdf_generator import merge_pdfs
files = [
base64_jpg,
DataURI.from_file("test.pdf"),
base64_jpg1,
DataURI.from_file("test2.pdf"),
base64_jpg2,
DataURI.from_file("test3.pdf")
]
data = DataURI(merge_pdfs(files))
b = BytesIO(data.data) ## Some random BytesIO Object
with open("test333.pdf", "wb") as f:
f.write(b.getbuffer())
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
History
0.1.0 (2020-09-15)
First release on PyPI.
Metadata
Release files for carol-pdf-generator 0.1.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| carol_pdf_generator-0.1.12.tar.gz | 1.3 MB | Without provenance | Details for carol_pdf_generator-0.1.12.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| carol_pdf_generator-0.1.12-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for carol_pdf_generator-0.1.12-py2.py3-none-any.whl |
Total release size: 1.3 MB
Release files / carol_pdf_generator-0.1.12.tar.gz
| Download URL | carol_pdf_generator-0.1.12.tar.gz |
|---|---|
| Size | 1.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d03fbe0418ab65d7167f912bd6e84439e0abf55b6a4faf987cedc8f7a84c7c55
|
|
BLAKE2b-256 checksum How to use checksums |
90ed0f5485459e140f925b16c1353ee5e4f28b1c2af26b11f037651776c30877
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
|
Release files / carol_pdf_generator-0.1.12-py2.py3-none-any.whl
| Download URL | carol_pdf_generator-0.1.12-py2.py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
adfac0b4cbbf806aa2c8733287257c6f0215ed5e1227401d7ed3ba81088440eb
|
|
BLAKE2b-256 checksum How to use checksums |
0c7bedeb84ae4cdd88aed39433292bcc3cf6e23135f3df51736841ee812d3bb8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.7
|
Security for carol-pdf-generator 0.1.12
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.