Skip to content

Commit ab20aec

Browse files
committed
Don’t add /Info key in trailer if info dict is empty
The /Info key is forbidden by some variants, such as PDF/A-4.
1 parent 78550d4 commit ab20aec

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pydyf/__init__.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,6 @@ def __init__(self):
467467

468468
#: PDF :class:`Dictionary` containing the PDF’s metadata.
469469
self.info = Dictionary({})
470-
self.add_object(self.info)
471470

472471
#: PDF :class:`Dictionary` containing references to the other objects.
473472
self.catalog = Dictionary({
@@ -630,7 +629,9 @@ def write(self, output, version=b'1.7', identifier=False, compress=False):
630629
self.write_line(b'<<', output)
631630
self.write_line(f'/Size {len(self.objects)}'.encode(), output)
632631
self.write_line(b'/Root ' + self.catalog.reference, output)
633-
self.write_line(b'/Info ' + self.info.reference, output)
632+
if self.info:
633+
self.add_object(self.info)
634+
self.write_line(b'/Info ' + self.info.reference, output)
634635
if identifier:
635636
data = b''.join(
636637
obj.data for obj in self.objects if obj.free != 'f')

0 commit comments

Comments
 (0)