2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-10-31 19:02:30 +00:00

Round-trip tests with --json-stream-data=file

This commit is contained in:
Jay Berkenbilt 2022-05-19 20:56:10 -04:00
parent a83b7b0611
commit 907df2c823
3 changed files with 164 additions and 1 deletions

View File

@ -142,7 +142,32 @@ $td->runtest("check manual JSON to JSON to JSON",
{$td->FILE => "a.json", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
# QXXXQ file
$n_tests += 6;
$td->runtest("json-output with file",
{$td->COMMAND => "qpdf --json-output=2" .
" --json-stream-prefix=auto-1 --json-stream-data=file" .
" minimal.pdf a.json"},
{$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check file mode",
{$td->FILE => "a.json"},
{$td->FILE => "minimal-json-file.out"},
$td->NORMALIZE_NEWLINES);
$td->runtest("JSON to JSON with file",
{$td->COMMAND => "qpdf --json-input --json-output=2" .
" --json-stream-prefix=auto-2 --json-stream-data=file" .
" a.json -"},
{$td->FILE => "minimal-json-file-2.out", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
$td->runtest("JSON with file to qdf",
{$td->COMMAND => "qpdf --json-input --qdf --static-id" .
" a.json a.pdf"},
{$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("PDF to qdf",
{$td->COMMAND => "qpdf --qdf --static-id minimal.pdf b.pdf"},
{$td->STRING => "", $td->EXIT_STATUS => 0});
$td->runtest("check PDF",
{$td->FILE => "a.pdf"},
{$td->FILE => "b.pdf"});
cleanup();
$td->report($n_tests);

View File

@ -0,0 +1,69 @@
{
"qpdf-v2": {
"pdfversion": "1.3",
"maxobjectid": 6,
"objects": {
"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": {
"datafile": "auto-2-4",
"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
}
}
}
}
}

View File

@ -0,0 +1,69 @@
{
"qpdf-v2": {
"pdfversion": "1.3",
"maxobjectid": 6,
"objects": {
"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": {
"datafile": "auto-1-4",
"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
}
}
}
}
}