2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-02-07 14:18:24 +00:00

QPDFJob: pass capture output streams through to underlying QPDF

This commit is contained in:
Jay Berkenbilt 2022-04-18 11:24:17 -04:00
parent 877694a583
commit ce5c3bcad8
3 changed files with 32 additions and 1 deletions

View File

@ -703,6 +703,7 @@ QPDFJob::getEncryptionStatus()
void
QPDFJob::setQPDFOptions(QPDF& pdf)
{
pdf.setOutputStreams(this->m->cout, this->m->cerr);
if (m->ignore_xref_streams) {
pdf.setIgnoreXRefStreams(true);
}

View File

@ -5,4 +5,15 @@ usage: an input file name is required
error caught by run
finished config
usage: an input file name is required
output capture
calling run
captured stdout
Object is stream. Dictionary:
<< /Length 44 >>
captured stderr
WARNING: bad2.pdf: file is damaged
WARNING: bad2.pdf: can't find startxref
WARNING: bad2.pdf: Attempting to reconstruct cross-reference table
WARNING: bad2.pdf (object 4 0, offset 389): expected endobj
qpdf: operation succeeded with warnings
test 84 done

View File

@ -1734,7 +1734,8 @@ test_46(QPDF& pdf, char const* arg2)
}
std::cout << "/Bad1" << std::endl;
auto bad1 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf);
auto bad1 =
QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf);
assert(bad1.begin() == bad1.end());
assert(bad1.last() == bad1.end());
@ -3023,6 +3024,24 @@ test_84(QPDF& pdf, char const* arg2)
} catch (QPDFUsage& e) {
std::cout << "usage: " << e.what() << std::endl;
}
std::cout << "output capture" << std::endl;
std::ostringstream cout;
std::ostringstream cerr;
{
QPDFJob j;
j.setOutputStreams(&cout, &cerr);
j.config()
->inputFile("bad2.pdf")
->showObject("4,0")
->checkConfiguration();
std::cout << "calling run" << std::endl;
j.run();
std::cout << "captured stdout" << std::endl;
std::cout << cout.str();
std::cout << "captured stderr" << std::endl;
std::cout << cerr.str();
}
}
static void