-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
is-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFworkflow-bookmarksFrom a users perspective, bookmarks is the affected feature/workflowFrom a users perspective, bookmarks is the affected feature/workflow
Description
Replace this: Using add_bookmark in PdfMerger, the title is fine but none of the page numbers are applied to output PDF.
Environment
$ python -m platform
# Windows-10-10.0.22000-SP0
$ python -c "import PyPDF2;print(PyPDF2.__version__)"
# 2.1.0Code
This is a minimal, complete example that shows the issue:
merger = PdfMerger()
prevgrp = ""
pagenum = 1
bmrkinfo = {}
for label, url in adc_full[icao].items():
currgrp = get_group_name(label) # string
pdffile = download_pdf(url, tempfolder, label) # returns a PdfReader
merger.append(pdffile)
if prevgrp != currgrp:
bmrkinfo[currgrp] = {}
prevgrp = currgrp
lbl = label.split(':')[-1]
bmrkinfo[currgrp][lbl] = pagenum
pagenum += len(pdffile.pages)
for g, pdfgroup in bmrkinfo.items():
pgrp = list(pdfgroup.values())[0]
currmrk = merger.add_bookmark(g, pgrp)
if len(pdfgroup) > 1:
for l, p in pdfgroup.items():
merger.add_bookmark(l, p, currmrk)
merger.write(os.path.join(OUTPUT_DIR, icao+'.pdf'))Sorry I can't share the PDF file itself.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
is-bugFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFFrom a users perspective, this is a bug - a violation of the expected behavior with a compliant PDFworkflow-bookmarksFrom a users perspective, bookmarks is the affected feature/workflowFrom a users perspective, bookmarks is the affected feature/workflow