Merging upstream version 0.3.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
da72e8568c
commit
55aaff7962
2 changed files with 65 additions and 4 deletions
|
@ -2,6 +2,40 @@ Changelog
|
|||
=========
|
||||
|
||||
|
||||
Version 0.3.0
|
||||
-------------
|
||||
|
||||
Released on 2022-09-19.
|
||||
|
||||
New features:
|
||||
|
||||
* Support marked content
|
||||
* Allow version and ID to be specified when initializing PDF objects
|
||||
|
||||
Contributors:
|
||||
|
||||
* Guillaume Ayoub
|
||||
|
||||
Backers and sponsors:
|
||||
|
||||
* Grip Angebotssoftware
|
||||
* Manuel Barkhau
|
||||
* Crisp BV
|
||||
* SimonSoft
|
||||
* Menutech
|
||||
* Spacinov
|
||||
* KontextWork
|
||||
* René Fritz
|
||||
* NCC Group
|
||||
* Kobalt
|
||||
* Tom Pohl
|
||||
* John R Ellis
|
||||
* Moritz Mahringer
|
||||
* Gábor
|
||||
* Piotr Horzycki
|
||||
* Andrew Ittner
|
||||
|
||||
|
||||
Version 0.2.0
|
||||
-------------
|
||||
|
||||
|
@ -11,7 +45,7 @@ Dependencies:
|
|||
|
||||
* Python 3.7+ is now needed, Python 3.6 is not supported anymore
|
||||
|
||||
New features:
|
||||
New features:
|
||||
|
||||
* `d0be36b <https://github.com/CourtBouillon/pydyf/commit/d0be36b>`_:
|
||||
Allow to set PDF version
|
||||
|
|
|
@ -8,7 +8,7 @@ import zlib
|
|||
from codecs import BOM_UTF16_BE
|
||||
from hashlib import md5
|
||||
|
||||
VERSION = __version__ = '0.2.0'
|
||||
VERSION = __version__ = '0.3.0'
|
||||
|
||||
|
||||
def _to_bytes(item):
|
||||
|
@ -97,6 +97,15 @@ class Stream(Object):
|
|||
#: Compress the stream data if set to ``True``. Default is ``False``.
|
||||
self.compress = compress
|
||||
|
||||
def begin_marked_content(self, tag, property_list=None):
|
||||
"""Begin marked-content sequence."""
|
||||
self.stream.append(f'/{tag}')
|
||||
if property_list is None:
|
||||
self.stream.append(b'BMC')
|
||||
else:
|
||||
self.stream.append(property_list)
|
||||
self.stream.append(b'BDC')
|
||||
|
||||
def begin_text(self):
|
||||
"""Begin a text object."""
|
||||
self.stream.append(b'BT')
|
||||
|
@ -172,6 +181,10 @@ class Stream(Object):
|
|||
"""End path without filling or stroking."""
|
||||
self.stream.append(b'n')
|
||||
|
||||
def end_marked_content(self):
|
||||
"""End marked-content sequence."""
|
||||
self.stream.append(b'EMC')
|
||||
|
||||
def end_text(self):
|
||||
"""End text object."""
|
||||
self.stream.append(b'ET')
|
||||
|
@ -409,7 +422,18 @@ class Array(Object, list):
|
|||
|
||||
class PDF:
|
||||
"""PDF document."""
|
||||
def __init__(self):
|
||||
def __init__(self, version=b'1.7', identifier=None):
|
||||
"""Create a PDF document.
|
||||
|
||||
:param bytes version: PDF version.
|
||||
:param bytes identifier: PDF file identifier.
|
||||
|
||||
"""
|
||||
#: PDF version, as :obj:`bytes`.
|
||||
self.version = _to_bytes(version)
|
||||
#: PDF file identifier.
|
||||
self.identifier = identifier
|
||||
|
||||
#: Python :obj:`list` containing the PDF’s objects.
|
||||
self.objects = []
|
||||
|
||||
|
@ -470,7 +494,7 @@ class PDF:
|
|||
self.current_position += len(content) + 1
|
||||
output.write(content + b'\n')
|
||||
|
||||
def write(self, output, version=b'1.7', identifier=None):
|
||||
def write(self, output, version=None, identifier=None):
|
||||
"""Write PDF to output.
|
||||
|
||||
:param output: Output stream.
|
||||
|
@ -479,6 +503,9 @@ class PDF:
|
|||
:param bytes identifier: PDF file identifier.
|
||||
|
||||
"""
|
||||
version = self.version if version is None else _to_bytes(version)
|
||||
identifier = self.identifier if identifier is None else identifier
|
||||
|
||||
# Write header
|
||||
self.write_line(b'%PDF-' + version, output)
|
||||
self.write_line(b'%\xf0\x9f\x96\xa4', output)
|
||||
|
|
Loading…
Add table
Reference in a new issue