summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-04-18 17:24:17 +0200
committerJay Berkenbilt <ejb@ql.org>2022-04-18 17:24:17 +0200
commitce5c3bcad81c264c90a429ec505a581680ce35a1 (patch)
tree619784ef97a51f7936d43b89b19810199408a41e
parent877694a5835a11120ef2bd1d2b82b609cb32ca07 (diff)
downloadqpdf-ce5c3bcad81c264c90a429ec505a581680ce35a1.tar.zst
QPDFJob: pass capture output streams through to underlying QPDF
-rw-r--r--libqpdf/QPDFJob.cc1
-rw-r--r--qpdf/qtest/qpdf/job-api.out11
-rw-r--r--qpdf/test_driver.cc21
3 files changed, 32 insertions, 1 deletions
diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc
index b8d91b69..af7a7c38 100644
--- a/libqpdf/QPDFJob.cc
+++ b/libqpdf/QPDFJob.cc
@@ -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);
}
diff --git a/qpdf/qtest/qpdf/job-api.out b/qpdf/qtest/qpdf/job-api.out
index 47b00ecf..d69b2ac9 100644
--- a/qpdf/qtest/qpdf/job-api.out
+++ b/qpdf/qtest/qpdf/job-api.out
@@ -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
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index da2a5e7f..14c6c316 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -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