qpdf / qpdf

qpdf: A content-preserving PDF document transformer
https://qpdf.sourceforge.io/
Apache License 2.0
3.43k stars 271 forks source link

Which API calls to delete outline entries for non-existing pages? #323

Open vindaddo opened 5 years ago

vindaddo commented 5 years ago

After calling removePage to delete a page from the pdf, I would like to remove any dangling outline entries that point to that page. The manual states:

For example, the document's outlines (bookmarks) point to actual page objects, so if you select some pages and not others, bookmarks that point to pages that are in the output file will work, and remaining bookmarks will not work. A future version of qpdf may do a better job at handling these issues. (Note that the qpdf library already contains all of the APIs required in order to implement this in your own application if you need it.)

So according to the manual it should be possible, I just can't find it.

jberkenbilt commented 5 years ago

You could do it, but you'd have to write a lot of code, and it would be complicated. However, it is on my roadmap and I expect to do it soon, so if you hold out a little longer, there may be a convenient way to do it in the API. If you want a sneak preview at my current thinking, you can look at the TODO file at the top of the source tree and find the section called "Page splitting/merging". Note that these are just my scratch notes. When I actually implement it, my thinking will likely evolve, and my final solution will probably deviate somewhat from this.

From the CLI, qpdf 8.3.0 and 8.4.0 made some attempt to preserve outlines during page splitting, but I backed it out for 8.4.1 (to be released in the next few days) because it didn't do something reasonable and imposed a heavy performance penalty.

jberkenbilt commented 9 months ago

I am beginning work on some features that should make this possible. I'm adding the pages label. I'll update or reference issues with this label when the feature is working.

jberkenbilt commented 9 months ago

This issue is part of the qpdf pages epic. If you are interested in following, please see #1104.