Commit caab1b0e1642bc6ee0194c7ab4c4a4de2ab22f2c
1 parent
4071db59
Handle pages with no /Contents from getPageContents()
The spec allows /Contents to be omitted for pages that are blank, but QPDFObjectHandle::getPageContents() was throwing an exception in this case.
Showing
5 changed files
with
23 additions
and
2 deletions
ChangeLog
| 1 | +2014-11-14 Jay Berkenbilt <ejb@ql.org> | ||
| 2 | + | ||
| 3 | + * Bug fix: QPDFObjectHandle::getPageContents() no longer throws an | ||
| 4 | + exception when called on a page that has no /Contents key in its | ||
| 5 | + dictionary. This is allowed by the spec, and some software | ||
| 6 | + packages generate files like this for pages that are blank in the | ||
| 7 | + original. | ||
| 8 | + | ||
| 1 | 2014-06-07 Jay Berkenbilt <ejb@ql.org> | 9 | 2014-06-07 Jay Berkenbilt <ejb@ql.org> |
| 2 | 10 | ||
| 3 | * 5.1.2: release | 11 | * 5.1.2: release |
libqpdf/QPDFObjectHandle.cc
| @@ -633,7 +633,7 @@ QPDFObjectHandle::getPageContents() | @@ -633,7 +633,7 @@ QPDFObjectHandle::getPageContents() | ||
| 633 | { | 633 | { |
| 634 | result.push_back(contents); | 634 | result.push_back(contents); |
| 635 | } | 635 | } |
| 636 | - else | 636 | + else if (! contents.isNull()) |
| 637 | { | 637 | { |
| 638 | throw std::runtime_error("unknown object type inspecting /Contents " | 638 | throw std::runtime_error("unknown object type inspecting /Contents " |
| 639 | "key in page dictionary"); | 639 | "key in page dictionary"); |
qpdf/qtest/qpdf.test
| @@ -199,7 +199,7 @@ $td->runtest("remove page we don't have", | @@ -199,7 +199,7 @@ $td->runtest("remove page we don't have", | ||
| 199 | show_ntests(); | 199 | show_ntests(); |
| 200 | # ---------- | 200 | # ---------- |
| 201 | $td->notify("--- Miscellaneous Tests ---"); | 201 | $td->notify("--- Miscellaneous Tests ---"); |
| 202 | -$n_tests += 72; | 202 | +$n_tests += 73; |
| 203 | 203 | ||
| 204 | $td->runtest("qpdf version", | 204 | $td->runtest("qpdf version", |
| 205 | {$td->COMMAND => "qpdf --version"}, | 205 | {$td->COMMAND => "qpdf --version"}, |
| @@ -554,6 +554,11 @@ $td->runtest("check file", | @@ -554,6 +554,11 @@ $td->runtest("check file", | ||
| 554 | {$td->FILE => "a.pdf"}, | 554 | {$td->FILE => "a.pdf"}, |
| 555 | {$td->FILE => "indirect-decode-parms-out.pdf"}); | 555 | {$td->FILE => "indirect-decode-parms-out.pdf"}); |
| 556 | 556 | ||
| 557 | +$td->runtest("handle page no with contents", | ||
| 558 | + {$td->COMMAND => "qpdf --show-pages page-no-content.pdf"}, | ||
| 559 | + {$td->FILE => "page-no-content.out", $td->EXIT_STATUS => 0}, | ||
| 560 | + $td->NORMALIZE_NEWLINES); | ||
| 561 | + | ||
| 557 | show_ntests(); | 562 | show_ntests(); |
| 558 | # ---------- | 563 | # ---------- |
| 559 | $td->notify("--- Numeric range parsing tests ---"); | 564 | $td->notify("--- Numeric range parsing tests ---"); |
qpdf/qtest/qpdf/page-no-content.out
0 → 100644
qpdf/qtest/qpdf/page-no-content.pdf
0 → 100644
No preview for this file type