QPDFJob: have doJSON write to a pipeline

This commit is contained in:
Jay Berkenbilt 2022-05-06 16:37:37 -04:00
parent 2a92b1b0d6
commit 7604ac5cb2
2 changed files with 8 additions and 4 deletions

View File

@ -39,6 +39,7 @@
#include <vector>
class QPDFWriter;
class Pipeline;
class QPDFJob
{
@ -509,7 +510,7 @@ class QPDFJob
void writeOutfile(QPDF& pdf);
// JSON
void doJSON(QPDF& pdf);
void doJSON(QPDF& pdf, Pipeline*);
std::set<QPDFObjGen> getWantedJSONObjects();
void doJSONObjects(QPDF& pdf, JSON& j);
void doJSONObjectinfo(QPDF& pdf, JSON& j);

View File

@ -14,6 +14,7 @@
#include <qpdf/Pl_DCT.hh>
#include <qpdf/Pl_Discard.hh>
#include <qpdf/Pl_Flate.hh>
#include <qpdf/Pl_OStream.hh>
#include <qpdf/Pl_StdioFile.hh>
#include <qpdf/QTC.hh>
#include <qpdf/QUtil.hh>
@ -1588,7 +1589,7 @@ QPDFJob::json_out_schema_v1()
}
void
QPDFJob::doJSON(QPDF& pdf)
QPDFJob::doJSON(QPDF& pdf, Pipeline* p)
{
JSON j = JSON::makeDictionary();
// This version is updated every time a non-backward-compatible
@ -1665,7 +1666,7 @@ ideally with the file that caused the error and the output below. Thanks!\n\
}
}
*(this->m->cout) << j.unparse() << std::endl;
*p << j.unparse() << "\n";
}
void
@ -1675,7 +1676,9 @@ QPDFJob::doInspection(QPDF& pdf)
doCheck(pdf);
}
if (m->json_version) {
doJSON(pdf);
Pl_OStream os("stdout", *(this->m->cout));
doJSON(pdf, &os);
os.finish();
}
if (m->show_npages) {
QTC::TC("qpdf", "QPDFJob npages");