Skip to content
Discussion options

You must be logged in to vote

@jstrumbo
Here is an example I could manage to do what you want using named destinations. On the TOC I pinned all destinations to page 1, and after merging I manipulated the named destinations on pypdf:

for b in bookmarks: 
    indent = "    " * b["depth"]
    title = f"{indent}{b['title']}"
    page_str = str(b["page"])
    max_width = toc.epw
    title_width = toc.get_string_width(title)
    page_width = toc.get_string_width(page_str)
    dot_width = toc.get_string_width(".")
    dots_needed = int((max_width - title_width - page_width) / dot_width)
    dots = "." * max(0, dots_needed)
    line = f"{title}{dots} {page_str}"

    # Here I resolve the named destination to page 1
    # so F…

Replies: 3 comments 9 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@jstrumbo
Comment options

@andersonhc
Comment options

@jstrumbo
Comment options

@andersonhc
Comment options

Answer selected by jstrumbo
Comment options

You must be logged in to vote
5 replies
@andersonhc
Comment options

@jstrumbo
Comment options

@Lucas-C
Comment options

@Lucas-C
Comment options

@jstrumbo
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants