Skip to content

Commit

Permalink
Add page numbers in marked content and set PDF as marked
Browse files Browse the repository at this point in the history
  • Loading branch information
liZe committed Oct 10, 2022
1 parent ab914a5 commit d275dac
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/first_steps.rst
Expand Up @@ -11,7 +11,7 @@ WeasyPrint |version| depends on:

* Python_ ≥ 3.7.0
* Pango_ ≥ 1.44.0
* pydyf_ ≥ 0.3.0
* pydyf_ ≥ 0.4.0
* CFFI_ ≥ 0.6
* html5lib_ ≥ 1.1
* tinycss2_ ≥ 1.0.0
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Expand Up @@ -12,7 +12,7 @@ requires-python = '>=3.7'
readme = {file = 'README.rst', content-type = 'text/x-rst'}
license = {file = 'LICENSE'}
dependencies = [
'pydyf >=0.3.0',
'pydyf >=0.4.0',
'cffi >=0.6',
'html5lib >=1.1',
'tinycss2 >=1.0.0',
Expand Down
3 changes: 1 addition & 2 deletions weasyprint/pdf/__init__.py
Expand Up @@ -208,8 +208,7 @@ def _create_bookmarks(bookmarks, pdf, parent=None):
count = len(bookmarks)
outlines = []
for title, (page, x, y), children, state in bookmarks:
destination = pydyf.Array((
pdf.objects[pdf.pages['Kids'][page*3]].reference, '/XYZ', x, y, 0))
destination = pydyf.Array((pdf.pages['Kids'][page], '/XYZ', x, y, 0))
outline = pydyf.Dictionary({
'Title': pydyf.String(title), 'Dest': destination})
pdf.add_object(outline)
Expand Down
3 changes: 3 additions & 0 deletions weasyprint/pdf/pdfua.py
Expand Up @@ -62,6 +62,7 @@ def pdfua(pdf, metadata, document, page_streams):
'Type': '/StructElem',
'S': f'/{key}',
'K': pydyf.Array(kids),
'Pg': pdf.pages['Kids'][page_number],
})
pdf.add_object(child)
if key == 'LI':
Expand All @@ -73,6 +74,7 @@ def pdfua(pdf, metadata, document, page_streams):
'Type': '/StructElem',
'S': f'/{sub_key}',
'K': pydyf.Array(kids),
'Pg': pdf.pages['Kids'][page_number],
'P': child.reference,
})
pdf.add_object(real_child)
Expand Down Expand Up @@ -115,6 +117,7 @@ def pdfua(pdf, metadata, document, page_streams):
pdf.catalog['ViewerPreferences'] = pydyf.Dictionary({
'DisplayDocTitle': 'true',
})
pdf.catalog['MarkInfo'] = pydyf.Dictionary({'Marked': 'true'})


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

0 comments on commit d275dac

Please sign in to comment.