mirror of
https://github.com/qpdf/qpdf.git
synced 2024-11-01 03:12:29 +00:00
Have qpdf --check parse content streams
Also move writing to null and parsing of content streams out of the wrong if block.
This commit is contained in:
parent
34311a89c5
commit
a7e8b8c789
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
2013-01-24 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
|
* qpdf --check now does syntactic checks all pages' content
|
||||||
|
streams as well as checking overall document structure. Semantic
|
||||||
|
errors are still not checked, and there are no plans to add
|
||||||
|
semantic checks.
|
||||||
|
|
||||||
|
* Bug fix: in versions 4.0.0 and 4.0.1, qpdf --check wasn't doing
|
||||||
|
as full of a check for linearized files as for non-linearized
|
||||||
|
files.
|
||||||
|
|
||||||
2013-01-22 Jay Berkenbilt <ejb@ql.org>
|
2013-01-22 Jay Berkenbilt <ejb@ql.org>
|
||||||
|
|
||||||
* Add QPDFObjectHandle::getTypeCode(). This method returns a
|
* Add QPDFObjectHandle::getTypeCode(). This method returns a
|
||||||
|
41
qpdf/qpdf.cc
41
qpdf/qpdf.cc
@ -46,6 +46,14 @@ struct QPDFPageData
|
|||||||
std::vector<int> selected_pages;
|
std::vector<int> selected_pages;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DiscardContents: public QPDFObjectHandle::ParserCallbacks
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~DiscardContents() {}
|
||||||
|
virtual void handleObject(QPDFObjectHandle) {}
|
||||||
|
virtual void handleEOF() {}
|
||||||
|
};
|
||||||
|
|
||||||
// Note: let's not be too noisy about documenting the fact that this
|
// Note: let's not be too noisy about documenting the fact that this
|
||||||
// software purposely fails to enforce the distinction between user
|
// software purposely fails to enforce the distinction between user
|
||||||
// and owner passwords. A user password is sufficient to gain full
|
// and owner passwords. A user password is sufficient to gain full
|
||||||
@ -1442,16 +1450,29 @@ int main(int argc, char* argv[])
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "File is not linearized\n";
|
std::cout << "File is not linearized\n";
|
||||||
// Write the file no nowhere, uncompressing
|
}
|
||||||
// streams. This causes full file traversal
|
|
||||||
// and decoding of all streams we can decode.
|
// Write the file no nowhere, uncompressing
|
||||||
QPDFWriter w(pdf);
|
// streams. This causes full file traversal
|
||||||
Pl_Discard discard;
|
// and decoding of all streams we can decode.
|
||||||
w.setOutputPipeline(&discard);
|
QPDFWriter w(pdf);
|
||||||
w.setStreamDataMode(qpdf_s_uncompress);
|
Pl_Discard discard;
|
||||||
w.write();
|
w.setOutputPipeline(&discard);
|
||||||
okay = true;
|
w.setStreamDataMode(qpdf_s_uncompress);
|
||||||
}
|
w.write();
|
||||||
|
|
||||||
|
// Parse all content streams
|
||||||
|
std::vector<QPDFObjectHandle> pages = pdf.getAllPages();
|
||||||
|
DiscardContents discard_contents;
|
||||||
|
for (std::vector<QPDFObjectHandle>::iterator iter =
|
||||||
|
pages.begin();
|
||||||
|
iter != pages.end(); ++iter)
|
||||||
|
{
|
||||||
|
QPDFObjectHandle::parseContentStream(
|
||||||
|
(*iter).getKey("/Contents"), &discard_contents);
|
||||||
|
}
|
||||||
|
|
||||||
|
okay = true;
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user