Commit 4ccb29912a28e78b130091b8e66ccaa79c626ae7
1 parent
131a21d3
Tighten isPageObject (fixes #310)
Showing
2 changed files
with
14 additions
and
5 deletions
ChangeLog
| 1 | 1 | 2019-04-20 Jay Berkenbilt <ejb@ql.org> |
| 2 | 2 | |
| 3 | + * Slightly tighten logic that determines whether an object is a | |
| 4 | + page. The previous logic was sometimes failing to preserve | |
| 5 | + annotations because they were passing the overly loose test for | |
| 6 | + whether something was a page. This fix has a slight risk of | |
| 7 | + causing some extraneous objects to be copied during page splitting | |
| 8 | + and merging for erroneous PDF files whose page objects contain | |
| 9 | + invalid types or are missing the /Type key entirely, both of which | |
| 10 | + would be invalid according to the PDF specification. | |
| 11 | + | |
| 3 | 12 | * Revert change that included preservation of outlines (bookmarks) |
| 4 | 13 | in --split-pages. The way it was implemented caused a very |
| 5 | 14 | significant performance penalty when splitting pages with | ... | ... |
libqpdf/QPDFObjectHandle.cc
| ... | ... | @@ -2524,14 +2524,14 @@ QPDFObjectHandle::isPageObject() |
| 2524 | 2524 | return true; |
| 2525 | 2525 | } |
| 2526 | 2526 | // Files have been seen in the wild that have /Type (Page) |
| 2527 | - if (type.isString() && (type.getStringValue() == "Page")) | |
| 2527 | + else if (type.isString() && (type.getStringValue() == "Page")) | |
| 2528 | 2528 | { |
| 2529 | 2529 | return true; |
| 2530 | 2530 | } |
| 2531 | - } | |
| 2532 | - if (this->hasKey("/Contents")) | |
| 2533 | - { | |
| 2534 | - return true; | |
| 2531 | + else | |
| 2532 | + { | |
| 2533 | + return false; | |
| 2534 | + } | |
| 2535 | 2535 | } |
| 2536 | 2536 | return false; |
| 2537 | 2537 | } | ... | ... |