Skip to content

Commit d275dac

Browse files
committed
Add page numbers in marked content and set PDF as marked
1 parent ab914a5 commit d275dac

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

docs/first_steps.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ WeasyPrint |version| depends on:
1111

1212
* Python_ ≥ 3.7.0
1313
* Pango_ ≥ 1.44.0
14-
* pydyf_ ≥ 0.3.0
14+
* pydyf_ ≥ 0.4.0
1515
* CFFI_ ≥ 0.6
1616
* html5lib_ ≥ 1.1
1717
* tinycss2_ ≥ 1.0.0

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ requires-python = '>=3.7'
1212
readme = {file = 'README.rst', content-type = 'text/x-rst'}
1313
license = {file = 'LICENSE'}
1414
dependencies = [
15-
'pydyf >=0.3.0',
15+
'pydyf >=0.4.0',
1616
'cffi >=0.6',
1717
'html5lib >=1.1',
1818
'tinycss2 >=1.0.0',

weasyprint/pdf/__init__.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ def _create_bookmarks(bookmarks, pdf, parent=None):
208208
count = len(bookmarks)
209209
outlines = []
210210
for title, (page, x, y), children, state in bookmarks:
211-
destination = pydyf.Array((
212-
pdf.objects[pdf.pages['Kids'][page*3]].reference, '/XYZ', x, y, 0))
211+
destination = pydyf.Array((pdf.pages['Kids'][page], '/XYZ', x, y, 0))
213212
outline = pydyf.Dictionary({
214213
'Title': pydyf.String(title), 'Dest': destination})
215214
pdf.add_object(outline)

weasyprint/pdf/pdfua.py

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def pdfua(pdf, metadata, document, page_streams):
6262
'Type': '/StructElem',
6363
'S': f'/{key}',
6464
'K': pydyf.Array(kids),
65+
'Pg': pdf.pages['Kids'][page_number],
6566
})
6667
pdf.add_object(child)
6768
if key == 'LI':
@@ -73,6 +74,7 @@ def pdfua(pdf, metadata, document, page_streams):
7374
'Type': '/StructElem',
7475
'S': f'/{sub_key}',
7576
'K': pydyf.Array(kids),
77+
'Pg': pdf.pages['Kids'][page_number],
7678
'P': child.reference,
7779
})
7880
pdf.add_object(real_child)
@@ -115,6 +117,7 @@ def pdfua(pdf, metadata, document, page_streams):
115117
pdf.catalog['ViewerPreferences'] = pydyf.Dictionary({
116118
'DisplayDocTitle': 'true',
117119
})
120+
pdf.catalog['MarkInfo'] = pydyf.Dictionary({'Marked': 'true'})
118121

119122

120123
VARIANTS = {'pdf/ua-1': (pdfua, {'mark': True})}

0 commit comments

Comments
 (0)