Skip to content

Commit 419c771

Browse files
committed
Use reference instead of stream for annotation appearance stream
Fix #1764.
1 parent ccd305e commit 419c771

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

weasyprint/pdf/__init__.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -369,18 +369,21 @@ def generate_pdf(document, target, zoom, attachments, optimize_size,
369369
rectangle = (
370370
*matrix.transform_point(*rectangle[:2]),
371371
*matrix.transform_point(*rectangle[2:]))
372+
stream = pydyf.Stream([], {
373+
'Type': '/XObject',
374+
'Subtype': '/Form',
375+
'BBox': pydyf.Array(rectangle),
376+
'Length': 0,
377+
})
378+
pdf.add_object(stream)
372379
annot = pydyf.Dictionary({
373380
'Type': '/Annot',
374381
'Rect': pydyf.Array(rectangle),
375382
'Subtype': '/FileAttachment',
376383
'T': pydyf.String(),
377384
'FS': annot_file.reference,
378-
'AP': pydyf.Dictionary({'N': pydyf.Stream([], {
379-
'Type': '/XObject',
380-
'Subtype': '/Form',
381-
'BBox': pydyf.Array(rectangle),
382-
'Length': 0,
383-
})})
385+
'AP': pydyf.Dictionary({'N': stream.reference}),
386+
'AS': '/N',
384387
})
385388
pdf.add_object(annot)
386389
if 'Annots' not in pdf_page:

0 commit comments

Comments
 (0)