Commit ce5c3bcad81c264c90a429ec505a581680ce35a1

Authored by Jay Berkenbilt
1 parent 877694a5

QPDFJob: pass capture output streams through to underlying QPDF

libqpdf/QPDFJob.cc
... ... @@ -703,6 +703,7 @@ QPDFJob::getEncryptionStatus()
703 703 void
704 704 QPDFJob::setQPDFOptions(QPDF& pdf)
705 705 {
  706 + pdf.setOutputStreams(this->m->cout, this->m->cerr);
706 707 if (m->ignore_xref_streams) {
707 708 pdf.setIgnoreXRefStreams(true);
708 709 }
... ...
qpdf/qtest/qpdf/job-api.out
... ... @@ -5,4 +5,15 @@ usage: an input file name is required
5 5 error caught by run
6 6 finished config
7 7 usage: an input file name is required
  8 +output capture
  9 +calling run
  10 +captured stdout
  11 +Object is stream. Dictionary:
  12 +<< /Length 44 >>
  13 +captured stderr
  14 +WARNING: bad2.pdf: file is damaged
  15 +WARNING: bad2.pdf: can't find startxref
  16 +WARNING: bad2.pdf: Attempting to reconstruct cross-reference table
  17 +WARNING: bad2.pdf (object 4 0, offset 389): expected endobj
  18 +qpdf: operation succeeded with warnings
8 19 test 84 done
... ...
qpdf/test_driver.cc
... ... @@ -1734,7 +1734,8 @@ test_46(QPDF&amp; pdf, char const* arg2)
1734 1734 }
1735 1735  
1736 1736 std::cout << "/Bad1" << std::endl;
1737   - auto bad1 = QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf);
  1737 + auto bad1 =
  1738 + QPDFNumberTreeObjectHelper(pdf.getTrailer().getKey("/Bad1"), pdf);
1738 1739 assert(bad1.begin() == bad1.end());
1739 1740 assert(bad1.last() == bad1.end());
1740 1741  
... ... @@ -3023,6 +3024,24 @@ test_84(QPDF&amp; pdf, char const* arg2)
3023 3024 } catch (QPDFUsage& e) {
3024 3025 std::cout << "usage: " << e.what() << std::endl;
3025 3026 }
  3027 +
  3028 + std::cout << "output capture" << std::endl;
  3029 + std::ostringstream cout;
  3030 + std::ostringstream cerr;
  3031 + {
  3032 + QPDFJob j;
  3033 + j.setOutputStreams(&cout, &cerr);
  3034 + j.config()
  3035 + ->inputFile("bad2.pdf")
  3036 + ->showObject("4,0")
  3037 + ->checkConfiguration();
  3038 + std::cout << "calling run" << std::endl;
  3039 + j.run();
  3040 + std::cout << "captured stdout" << std::endl;
  3041 + std::cout << cout.str();
  3042 + std::cout << "captured stderr" << std::endl;
  3043 + std::cout << cerr.str();
  3044 + }
3026 3045 }
3027 3046  
3028 3047 static void
... ...