Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table of contents missing in converted files #19

Open
syu-id opened this issue Oct 1, 2019 · 1 comment
Open

Table of contents missing in converted files #19

syu-id opened this issue Oct 1, 2019 · 1 comment

Comments

@syu-id
Copy link

syu-id commented Oct 1, 2019

Table of contents / outline of PDF files is not preserved after conversion. This would make it very difficult to navigate some long articles.

@syu-id
Copy link
Author

syu-id commented Oct 2, 2019

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant