Commit f08ce00e626f193925ff4145b48fef4a9f51387a

Authored by Jay Berkenbilt
1 parent 4b908ade

Add tests for PCLm

Files written in PCLm mode have to be created in a very specific way.
qpdf doesn't know how to create PCLm files from scratch. All it knows
how to do is to write an already valid file in a suitable way.
Therefore there is no command-line support for PCLm.
qpdf/qtest/qpdf.test
@@ -917,6 +917,19 @@ $td->runtest("check output", @@ -917,6 +917,19 @@ $td->runtest("check output",
917 {$td->FILE => "from-scratch-0.pdf"}); 917 {$td->FILE => "from-scratch-0.pdf"});
918 show_ntests(); 918 show_ntests();
919 # ---------- 919 # ----------
  920 +$td->notify("--- PCLm ---");
  921 +$n_tests += 2;
  922 +
  923 +$td->runtest("write as PCLm",
  924 + {$td->COMMAND => "test_driver 40 pclm-in.pdf a.pdf"},
  925 + {$td->STRING => "test 40 done\n", $td->EXIT_STATUS => 0},
  926 + $td->NORMALIZE_NEWLINES);
  927 +$td->runtest("check output",
  928 + {$td->FILE => "a.pdf"},
  929 + {$td->FILE => "pclm-out.pdf"});
  930 +
  931 +show_ntests();
  932 +# ----------
920 $td->notify("--- Precheck streams ---"); 933 $td->notify("--- Precheck streams ---");
921 $n_tests += 2; 934 $n_tests += 2;
922 935
qpdf/qtest/qpdf/pclm-in.pdf 0 → 100644
No preview for this file type
qpdf/qtest/qpdf/pclm-out.pdf 0 → 100644
No preview for this file type
qpdf/test_driver.cc
@@ -1334,6 +1334,18 @@ void runtest(int n, char const* filename1, char const* arg2) @@ -1334,6 +1334,18 @@ void runtest(int n, char const* filename1, char const* arg2)
1334 } 1334 }
1335 } 1335 }
1336 } 1336 }
  1337 + else if (n == 40)
  1338 + {
  1339 + // Write PCLm. This requires specially crafted PDF files. This
  1340 + // feature was implemented by Sahil Arora
  1341 + // <sahilarora.535@gmail.com> as part of a Google Summer of
  1342 + // Code project in 2017.
  1343 + assert(arg2 != 0);
  1344 + QPDFWriter w(pdf, arg2);
  1345 + w.setPCLm(true);
  1346 + w.setStaticID(true);
  1347 + w.write();
  1348 + }
1337 else 1349 else
1338 { 1350 {
1339 throw std::runtime_error(std::string("invalid test ") + 1351 throw std::runtime_error(std::string("invalid test ") +