aboutsummaryrefslogtreecommitdiffstats
path: root/qpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-07-31 21:26:24 +0200
committerJay Berkenbilt <ejb@ql.org>2022-07-31 22:23:17 +0200
commit12d065c75120d68cb7dd8445be4620e003598d7d (patch)
treedd190dfe50b68297109dfd4b1bc098f8e489cab3 /qpdf
parent13cf35ce2f39780b5ce35fd65be4b0ae44ea989d (diff)
downloadqpdf-12d065c75120d68cb7dd8445be4620e003598d7d.tar.zst
Provide a simpler QPDF::writeJSON
Diffstat (limited to 'qpdf')
-rw-r--r--qpdf/qtest/qpdf-json.test6
-rw-r--r--qpdf/qtest/qpdf/minimal-write-json.json75
-rw-r--r--qpdf/test_driver.cc11
3 files changed, 91 insertions, 1 deletions
diff --git a/qpdf/qtest/qpdf-json.test b/qpdf/qtest/qpdf-json.test
index 481cdca9..553a84e2 100644
--- a/qpdf/qtest/qpdf-json.test
+++ b/qpdf/qtest/qpdf-json.test
@@ -282,5 +282,11 @@ $td->runtest("check PDF (2)",
{$td->FILE => "a.pdf"},
{$td->FILE => "duplicate-page-inherited-2-fixed.pdf"});
+$n_tests += 1;
+$td->runtest("simple version of writeJSON",
+ {$td->COMMAND => "test_driver 91 minimal.pdf"},
+ {$td->FILE => "minimal-write-json.json", $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
+
cleanup();
$td->report($n_tests);
diff --git a/qpdf/qtest/qpdf/minimal-write-json.json b/qpdf/qtest/qpdf/minimal-write-json.json
new file mode 100644
index 00000000..7e86a841
--- /dev/null
+++ b/qpdf/qtest/qpdf/minimal-write-json.json
@@ -0,0 +1,75 @@
+{
+ "qpdf": [
+ {
+ "jsonversion": 2,
+ "pdfversion": "1.3",
+ "pushedinheritedpageresources": false,
+ "calledgetallpages": false,
+ "maxobjectid": 6
+ },
+ {
+ "obj:1 0 R": {
+ "value": {
+ "/Pages": "2 0 R",
+ "/Type": "/Catalog"
+ }
+ },
+ "obj:2 0 R": {
+ "value": {
+ "/Count": 1,
+ "/Kids": [
+ "3 0 R"
+ ],
+ "/Type": "/Pages"
+ }
+ },
+ "obj:3 0 R": {
+ "value": {
+ "/Contents": "4 0 R",
+ "/MediaBox": [
+ 0,
+ 0,
+ 612,
+ 792
+ ],
+ "/Parent": "2 0 R",
+ "/Resources": {
+ "/Font": {
+ "/F1": "6 0 R"
+ },
+ "/ProcSet": "5 0 R"
+ },
+ "/Type": "/Page"
+ }
+ },
+ "obj:4 0 R": {
+ "stream": {
+ "data": "QlQKICAvRjEgMjQgVGYKICA3MiA3MjAgVGQKICAoUG90YXRvKSBUagpFVAo=",
+ "dict": {}
+ }
+ },
+ "obj:5 0 R": {
+ "value": [
+ "/PDF",
+ "/Text"
+ ]
+ },
+ "obj:6 0 R": {
+ "value": {
+ "/BaseFont": "/Helvetica",
+ "/Encoding": "/WinAnsiEncoding",
+ "/Name": "/F1",
+ "/Subtype": "/Type1",
+ "/Type": "/Font"
+ }
+ },
+ "trailer": {
+ "value": {
+ "/Root": "1 0 R",
+ "/Size": 7
+ }
+ }
+ }
+ ]
+}
+test 91 done
diff --git a/qpdf/test_driver.cc b/qpdf/test_driver.cc
index 8378c8fa..aa4f9ce5 100644
--- a/qpdf/test_driver.cc
+++ b/qpdf/test_driver.cc
@@ -3249,6 +3249,15 @@ test_90(QPDF& pdf, char const* arg2)
pdf.getRoot().appendItem(QPDFObjectHandle::newNull());
}
+static void
+test_91(QPDF& pdf, char const* arg2)
+{
+ // Exercise the simpler version of writeJSON.
+ Pl_StdioFile p("stdout", stdout);
+ pdf.writeJSON(
+ 2, &p, qpdf_dl_none, qpdf_sj_inline, "", std::set<std::string>());
+}
+
void
runtest(int n, char const* filename1, char const* arg2)
{
@@ -3353,7 +3362,7 @@ runtest(int n, char const* filename1, char const* arg2)
{76, test_76}, {77, test_77}, {78, test_78}, {79, test_79},
{80, test_80}, {81, test_81}, {82, test_82}, {83, test_83},
{84, test_84}, {85, test_85}, {86, test_86}, {87, test_87},
- {88, test_88}, {89, test_89}, {90, test_90}};
+ {88, test_88}, {89, test_89}, {90, test_90}, {91, test_91}};
auto fn = test_functions.find(n);
if (fn == test_functions.end()) {