Open syu-id opened 4 years ago
Here is my quick solution, which copies the root of the original PDF to the output after annotations are merged.
# insert after the line:
# outpdf = add_annotation2pdf(inpdf, outpdf, annotations)
# Copy the root (document catalog) except for /Pages
# PDF Reference, Sixth Edition, version 1.7, p.137
# https://www.adobe.com/devnet/pdf/pdf_reference_archive.html
for k,v in inpdf.trailer["/Root"].items():
if k.getObject() != "/Pages":
outpdf._root_object.update({k: v})
See also: Xunius/Menotexport#22
Table of contents / outline of PDF files is not preserved after conversion. This would make it very difficult to navigate some long articles.