Skip to content

Commit

Permalink
Switch from parseContentStream to parsePageContents
Browse files Browse the repository at this point in the history
  • Loading branch information
jberkenbilt committed Feb 19, 2018
1 parent fcd611b commit 6afe839
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
problems are encountered as the error messages can include
information about which page the streams come from.

* Update content stream parsing example
(examples/pdf-parse-content.cc) to use new
QPDFObjectHandle::parsePageContents() method in favor of the older
QPDFObjectHandle::parseContentStream() method.

2018-02-04 Jay Berkenbilt <[email protected]>

* Add QPDFWriter::setLinearizationPass1Filename method and
Expand Down
3 changes: 1 addition & 2 deletions examples/pdf-parse-content.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,8 @@ int main(int argc, char* argv[])
}

QPDFObjectHandle page = pages.at(pageno-1);
QPDFObjectHandle contents = page.getKey("/Contents");
ParserCallbacks cb;
QPDFObjectHandle::parseContentStream(contents, &cb);
page.parsePageContents(&cb);
}
catch (std::exception& e)
{
Expand Down
4 changes: 1 addition & 3 deletions qpdf/qpdf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1769,9 +1769,7 @@ static void do_check(QPDF& pdf, Options& o, int& exit_code)
++pageno;
try
{
QPDFObjectHandle::parseContentStream(
(*iter).getKey("/Contents"),
&discard_contents);
(*iter).parsePageContents(&discard_contents);
}
catch (QPDFExc& e)
{
Expand Down
6 changes: 3 additions & 3 deletions qpdf/qtest/qpdf/content-stream-errors.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ checking content-stream-errors.pdf
PDF Version: 1.3
File is not encrypted
File is not linearized
page 1: content stream objects 7 0 (content, file position 52): parse error while reading object
page 3: content stream objects 15 0 (stream data, file position 117): EOF found while reading inline image
page 4: content stream objects 19 0 (content, file position 53): parse error while reading object
page 1: page object 3 0 stream 7 0 (content, file position 52): parse error while reading object
page 3: page object 5 0 stream 15 0 (stream data, file position 117): EOF found while reading inline image
page 4: page object 6 0 stream 19 0 (content, file position 53): parse error while reading object
2 changes: 1 addition & 1 deletion qpdf/qtest/qpdf/eof-in-inline-image.out
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ name: /Fl
name: /DP
dictionary: << /Columns 1 /Predictor 15 >>
operator: ID
content stream objects 4 0 (stream data, file position 139): EOF found while reading inline image
page object 3 0 stream 4 0 (stream data, file position 139): EOF found while reading inline image
2 changes: 1 addition & 1 deletion qpdf/qtest/qpdf/split-content-stream-errors.out
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ File is not encrypted
File is not linearized
WARNING: split-content-stream-errors.pdf (file position 557): error decoding stream data for object 6 0: LZWDecoder: bad code received
WARNING: split-content-stream-errors.pdf (file position 557): stream will be re-processed without filtering to avoid data loss
WARNING: content stream objects (item index 0 (from 0)): ignoring non-stream in an array of streams
WARNING: page object 3 0 (item index 0 (from 0)): ignoring non-stream in an array of streams
WARNING: split-content-stream-errors.pdf (file position 557): error decoding stream data for object 6 0: LZWDecoder: bad code received
WARNING: content stream (content stream object 6 0): errors while decoding content stream
3 changes: 1 addition & 2 deletions qpdf/test_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1296,9 +1296,8 @@ void runtest(int n, char const* filename1, char const* arg2)
iter != pages.end(); ++iter)
{
QPDFObjectHandle page = *iter;
QPDFObjectHandle contents = page.getKey("/Contents");
ParserCallbacks cb;
QPDFObjectHandle::parseContentStream(contents, &cb);
page.parsePageContents(&cb);
}
}
else if (n == 38)
Expand Down

0 comments on commit 6afe839

Please sign in to comment.