Commit 6afe83978fe1d310e8a41774c33052d880f2f524

Authored by Jay Berkenbilt
1 parent fcd611b6

Switch from parseContentStream to parsePageContents

ChangeLog
... ... @@ -57,6 +57,11 @@
57 57 problems are encountered as the error messages can include
58 58 information about which page the streams come from.
59 59  
  60 + * Update content stream parsing example
  61 + (examples/pdf-parse-content.cc) to use new
  62 + QPDFObjectHandle::parsePageContents() method in favor of the older
  63 + QPDFObjectHandle::parseContentStream() method.
  64 +
60 65 2018-02-04 Jay Berkenbilt <ejb@ql.org>
61 66  
62 67 * Add QPDFWriter::setLinearizationPass1Filename method and
... ...
examples/pdf-parse-content.cc
... ... @@ -75,9 +75,8 @@ int main(int argc, char* argv[])
75 75 }
76 76  
77 77 QPDFObjectHandle page = pages.at(pageno-1);
78   - QPDFObjectHandle contents = page.getKey("/Contents");
79 78 ParserCallbacks cb;
80   - QPDFObjectHandle::parseContentStream(contents, &cb);
  79 + page.parsePageContents(&cb);
81 80 }
82 81 catch (std::exception& e)
83 82 {
... ...
qpdf/qpdf.cc
... ... @@ -1769,9 +1769,7 @@ static void do_check(QPDF&amp; pdf, Options&amp; o, int&amp; exit_code)
1769 1769 ++pageno;
1770 1770 try
1771 1771 {
1772   - QPDFObjectHandle::parseContentStream(
1773   - (*iter).getKey("/Contents"),
1774   - &discard_contents);
  1772 + (*iter).parsePageContents(&discard_contents);
1775 1773 }
1776 1774 catch (QPDFExc& e)
1777 1775 {
... ...
qpdf/qtest/qpdf/content-stream-errors.out
... ... @@ -2,6 +2,6 @@ checking content-stream-errors.pdf
2 2 PDF Version: 1.3
3 3 File is not encrypted
4 4 File is not linearized
5   -page 1: content stream objects 7 0 (content, file position 52): parse error while reading object
6   -page 3: content stream objects 15 0 (stream data, file position 117): EOF found while reading inline image
7   -page 4: content stream objects 19 0 (content, file position 53): parse error while reading object
  5 +page 1: page object 3 0 stream 7 0 (content, file position 52): parse error while reading object
  6 +page 3: page object 5 0 stream 15 0 (stream data, file position 117): EOF found while reading inline image
  7 +page 4: page object 6 0 stream 19 0 (content, file position 53): parse error while reading object
... ...
qpdf/qtest/qpdf/eof-in-inline-image.out
... ... @@ -22,4 +22,4 @@ name: /Fl
22 22 name: /DP
23 23 dictionary: << /Columns 1 /Predictor 15 >>
24 24 operator: ID
25   -content stream objects 4 0 (stream data, file position 139): EOF found while reading inline image
  25 +page object 3 0 stream 4 0 (stream data, file position 139): EOF found while reading inline image
... ...
qpdf/qtest/qpdf/split-content-stream-errors.out
... ... @@ -4,6 +4,6 @@ File is not encrypted
4 4 File is not linearized
5 5 WARNING: split-content-stream-errors.pdf (file position 557): error decoding stream data for object 6 0: LZWDecoder: bad code received
6 6 WARNING: split-content-stream-errors.pdf (file position 557): stream will be re-processed without filtering to avoid data loss
7   -WARNING: content stream objects (item index 0 (from 0)): ignoring non-stream in an array of streams
  7 +WARNING: page object 3 0 (item index 0 (from 0)): ignoring non-stream in an array of streams
8 8 WARNING: split-content-stream-errors.pdf (file position 557): error decoding stream data for object 6 0: LZWDecoder: bad code received
9 9 WARNING: content stream (content stream object 6 0): errors while decoding content stream
... ...
qpdf/test_driver.cc
... ... @@ -1296,9 +1296,8 @@ void runtest(int n, char const* filename1, char const* arg2)
1296 1296 iter != pages.end(); ++iter)
1297 1297 {
1298 1298 QPDFObjectHandle page = *iter;
1299   - QPDFObjectHandle contents = page.getKey("/Contents");
1300 1299 ParserCallbacks cb;
1301   - QPDFObjectHandle::parseContentStream(contents, &cb);
  1300 + page.parsePageContents(&cb);
1302 1301 }
1303 1302 }
1304 1303 else if (n == 38)
... ...