diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-03 14:08:06 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-03 14:08:06 +0000 |
commit | f3470e5112deb4d84d2e9ce54aa886e26d3c6373 (patch) | |
tree | 9fa61e7d41db639244980bd1dbcbc637a20ec2dc /docs | |
parent | Adding upstream version 0.7.0. (diff) | |
download | pydyf-upstream/0.9.0.tar.xz pydyf-upstream/0.9.0.zip |
Adding upstream version 0.9.0.upstream/0.9.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/changelog.rst | 82 | ||||
-rw-r--r-- | docs/common_use_cases.rst | 84 | ||||
-rw-r--r-- | docs/conf.py | 3 |
3 files changed, 169 insertions, 0 deletions
diff --git a/docs/changelog.rst b/docs/changelog.rst index e116ac8..661a696 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,6 +2,88 @@ Changelog ========= +Version 0.9.0 +------------- + +Released on 2024-02-26. + +Dependencies: + +* Python 3.12 is supported and tested +* Python 3.8+ is now needed, Python 3.7 is not supported anymore + +New features: + +* Add inline images support + +Performance: + +* Simplify `_to_bytes()` + +Documentation: + +* Add sample to create a PDF with metadata + +Contributors: + +* Panagiotis H.M. Issaris +* Guillaume Ayoub +* Lucie Anglade + +Backers and sponsors: + +* Spacinov +* Kobalt +* Grip Angebotssoftware +* Manuel Barkhau +* SimonSoft +* Menutech +* KontextWork +* René Fritz +* Simon Sapin +* Arcanite +* TrainingSparkle +* Healthchecks.io +* Hammerbacher +* Docraptor +* Yanal-Yvez Fargialla +* Morntag +* NBCO + + +Version 0.8.0 +------------- + +Released on 2023-09-25. + +New features: + +* Add text rise operator + +Backers and sponsors: + +* Spacinov +* Kobalt +* Grip Angebotssoftware +* Manuel Barkhau +* SimonSoft +* Menutech +* KontextWork +* NCC Group +* René Fritz +* Nicola Auchmuty +* Syslifters +* Hammerbacher +* TrainingSparkle +* Daniel Kucharski +* Healthchecks.io +* Yanal-Yvez Fargialla +* WakaTime +* Paheko +* Synapsium +* DocRaptor + + Version 0.7.0 ------------- diff --git a/docs/common_use_cases.rst b/docs/common_use_cases.rst index b045fa6..d8343b3 100644 --- a/docs/common_use_cases.rst +++ b/docs/common_use_cases.rst @@ -179,3 +179,87 @@ Display text with open('document.pdf', 'wb') as f: document.write(f) + + +Add metadata +------------ + +.. code-block:: python + + import datetime + + import pydyf + + document = pydyf.PDF() + document.info['Author'] = pydyf.String('Jane Doe') + document.info['Creator'] = pydyf.String('pydyf') + document.info['Keywords'] = pydyf.String('some keywords') + document.info['Producer'] = pydyf.String('The producer') + document.info['Subject'] = pydyf.String('An example PDF') + document.info['Title'] = pydyf.String('A PDF containing metadata') + now = datetime.datetime.now() + document.info['CreationDate'] = pydyf.String(now.strftime('D:%Y%m%d%H%M%S')) + + document.add_page( + pydyf.Dictionary( + { + 'Type': '/Page', + 'Parent': document.pages.reference, + 'MediaBox': pydyf.Array([0, 0, 200, 200]), + } + ) + ) + + # 550 bytes PDF + with open('metadata.pdf', 'wb') as f: + document.write(f) + + +Display inline QR-code image +---------------------------- + +.. code-block:: python + + import pydyf + import qrcode + + # Create a QR code image + image = qrcode.make('Some data here') + raw_data = image.tobytes() + width = image.size[0] + height = image.size[1] + + document = pydyf.PDF() + stream = pydyf.Stream(compress=True) + stream.push_state() + x = 0 + y = 0 + stream.transform(width, 0, 0, height, x, y) + # Add the 1-bit grayscale image inline in the PDF + stream.inline_image(width, height, 'Gray', 1, raw_data) + stream.pop_state() + document.add_object(stream) + + # Put the image in the resources of the PDF + document.add_page( + pydyf.Dictionary( + { + 'Type': '/Page', + 'Parent': document.pages.reference, + 'MediaBox': pydyf.Array([0, 0, 400, 400]), + 'Resources': pydyf.Dictionary( + { + 'ProcSet': pydyf.Array( + ['/PDF', '/ImageB', '/ImageC', '/ImageI'] + ), + } + ), + 'Contents': stream.reference, + } + ) + ) + + # 909 bytes PDF + with open('qrcode.pdf', 'wb') as f: + document.write(f, compress=True) + diff --git a/docs/conf.py b/docs/conf.py index a08c175..c868316 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -46,6 +46,9 @@ html_theme_options = { 'collapse_navigation': False, } +# Favicon URL +html_favicon = 'https://www.courtbouillon.org/static/images/favicon.png' + # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". |