mirror of https://github.com/qpdf/qpdf.git
Add --to-json option
This commit is contained in:
parent
2e87d593eb
commit
e9390aeaaa
|
@ -44,6 +44,7 @@ QPDF_DLL Config* staticId();
|
|||
QPDF_DLL Config* suppressPasswordRecovery();
|
||||
QPDF_DLL Config* suppressRecovery();
|
||||
QPDF_DLL Config* testJsonSchema();
|
||||
QPDF_DLL Config* toJson();
|
||||
QPDF_DLL Config* verbose();
|
||||
QPDF_DLL Config* warningExit0();
|
||||
QPDF_DLL Config* withImages();
|
||||
|
|
14
job.sums
14
job.sums
|
@ -3,15 +3,15 @@ generate_auto_job 0514289f2deb3bf7c1a6e85ef7d99ad120321ef5a6fe49d76c5274c6a658d3
|
|||
include/qpdf/auto_job_c_att.hh 4c2b171ea00531db54720bf49a43f8b34481586ae7fb6cbf225099ee42bc5bb4
|
||||
include/qpdf/auto_job_c_copy_att.hh 50609012bff14fd82f0649185940d617d05d530cdc522185c7f3920a561ccb42
|
||||
include/qpdf/auto_job_c_enc.hh 28446f3c32153a52afa239ea40503e6cc8ac2c026813526a349e0cd4ae17ddd5
|
||||
include/qpdf/auto_job_c_main.hh 688959c4725a71e1340cccfb2cf780ec62ada5aa42a9c3c7c8a5cd8e85a4a17d
|
||||
include/qpdf/auto_job_c_main.hh 50214d1583d0384e70ce7c91d6bb92c58f8cc125490a680681cfffe6455a1dce
|
||||
include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c18911614fe8e568ec
|
||||
include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1
|
||||
job.yml e73b8190f3e314bcdc98edf3d61d72283e5d0ff603b3d8ae98c77bb36b80028f
|
||||
job.yml c046a750e0cf6889b920484ab937bcb999be55273d77b263cb227b82006fbb36
|
||||
libqpdf/qpdf/auto_job_decl.hh 74df4d7fdbdf51ecd0d58ce1e9844bb5525b9adac5a45f7c9a787ecdda2868df
|
||||
libqpdf/qpdf/auto_job_help.hh feac25cd7e45fd587ca3c9b8807a1aed2e5510b592e76ae5bac775b0e03ac0b2
|
||||
libqpdf/qpdf/auto_job_init.hh 7d98e1d4b213537b6d401a103a9d52c77aaea3e1164f06c3664625f6ebfa7e7d
|
||||
libqpdf/qpdf/auto_job_help.hh e9b37d33bfcbf165bfba21b6778df3f356b904a961bfae68f9638b85142a87e8
|
||||
libqpdf/qpdf/auto_job_init.hh 423157a51fa470fb45d6e341cc3fc8f044b5344f06f86475b37302610c7d8afd
|
||||
libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297
|
||||
libqpdf/qpdf/auto_job_json_init.hh 1c1dcefd9577638f04fa1b76c82ddb1d20d93017bb72782da2aca8a51d974770
|
||||
libqpdf/qpdf/auto_job_schema.hh 748b2e11754c5186b31098ab1b7963306fe0d5fd91445df914c105c8fac49c18
|
||||
libqpdf/qpdf/auto_job_json_init.hh eaed8624a1a394c75a3e298e1c31015146211e240d710509eb627fc711a387a6
|
||||
libqpdf/qpdf/auto_job_schema.hh a9971c82c9821a5ec620ccc003bcb3383c054e45658b50fa559b5855e694ed1a
|
||||
manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580
|
||||
manual/cli.rst 3901f7e099c2ebf29e81db7d93f3f19a92aff9e72ec6dfb0984a170cfcdd300f
|
||||
manual/cli.rst f1bbf59ce4fdb5a6d29fc2470788eee321423dd946984fc2e6f3a904fe5137c1
|
||||
|
|
2
job.yml
2
job.yml
|
@ -134,6 +134,7 @@ options:
|
|||
- suppress-password-recovery
|
||||
- suppress-recovery
|
||||
- test-json-schema
|
||||
- to-json
|
||||
- underlay
|
||||
- verbose
|
||||
- warning-exit-0
|
||||
|
@ -357,6 +358,7 @@ json:
|
|||
- null
|
||||
json-stream-data:
|
||||
json-stream-prefix:
|
||||
to-json:
|
||||
# other options
|
||||
allow-weak-crypto:
|
||||
keep-files-open:
|
||||
|
|
|
@ -283,6 +283,16 @@ QPDFJob::Config::jsonStreamPrefix(std::string const& parameter)
|
|||
return this;
|
||||
}
|
||||
|
||||
QPDFJob::Config*
|
||||
QPDFJob::Config::toJson()
|
||||
{
|
||||
json("latest");
|
||||
jsonStreamData("inline");
|
||||
jsonKey("qpdf");
|
||||
decodeLevel("none");
|
||||
return this;
|
||||
}
|
||||
|
||||
QPDFJob::Config*
|
||||
QPDFJob::Config::testJsonSchema()
|
||||
{
|
||||
|
|
|
@ -798,6 +798,10 @@ depth in the JSON section of the manual. "version" may be a
|
|||
specific version or "latest". Run qpdf --json-help for a
|
||||
description of the generated JSON object.
|
||||
)");
|
||||
ap.addOptionHelp("--to-json", "json", "serialize to JSON", R"(Shortcut for options useful for serializing PDF to JSON:
|
||||
--json=latest --json-stream-data=inline
|
||||
--json-key=qpdf --decode-level=none
|
||||
)");
|
||||
ap.addOptionHelp("--json-help", "json", "show format of JSON output", R"(Describe the format of the JSON output by writing to standard
|
||||
output a JSON object with the same keys and with values
|
||||
containing descriptive text.
|
||||
|
@ -839,14 +843,14 @@ ap.addOptionHelp("--static-id", "testing", "use a fixed document ID", R"(Use a f
|
|||
testing only. Never use it for production files. See also
|
||||
qpdf --help=--deterministic-id.
|
||||
)");
|
||||
}
|
||||
static void add_help_8(QPDFArgParser& ap)
|
||||
{
|
||||
ap.addOptionHelp("--static-aes-iv", "testing", "use a fixed AES vector", R"(Use a static initialization vector for AES-CBC. This is intended
|
||||
for testing only so that output files can be reproducible. Never
|
||||
use it for production files. This option is not secure since it
|
||||
significantly weakens the encryption.
|
||||
)");
|
||||
}
|
||||
static void add_help_8(QPDFArgParser& ap)
|
||||
{
|
||||
ap.addOptionHelp("--linearize-pass1", "testing", "save pass 1 of linearization", R"(--linearize-pass1=file
|
||||
|
||||
Write the first pass of linearization to the named file. The
|
||||
|
|
|
@ -79,6 +79,7 @@ this->ap.addBare("static-id", [this](){c_main->staticId();});
|
|||
this->ap.addBare("suppress-password-recovery", [this](){c_main->suppressPasswordRecovery();});
|
||||
this->ap.addBare("suppress-recovery", [this](){c_main->suppressRecovery();});
|
||||
this->ap.addBare("test-json-schema", [this](){c_main->testJsonSchema();});
|
||||
this->ap.addBare("to-json", [this](){c_main->toJson();});
|
||||
this->ap.addBare("underlay", b(&ArgParser::argUnderlay));
|
||||
this->ap.addBare("verbose", [this](){c_main->verbose();});
|
||||
this->ap.addBare("warning-exit-0", [this](){c_main->warningExit0();});
|
||||
|
|
|
@ -259,6 +259,9 @@ popHandler(); // key: jsonStreamData
|
|||
pushKey("jsonStreamPrefix");
|
||||
addParameter([this](std::string const& p) { c_main->jsonStreamPrefix(p); });
|
||||
popHandler(); // key: jsonStreamPrefix
|
||||
pushKey("toJson");
|
||||
addBare([this]() { c_main->toJson(); });
|
||||
popHandler(); // key: toJson
|
||||
pushKey("allowWeakCrypto");
|
||||
addBare([this]() { c_main->allowWeakCrypto(); });
|
||||
popHandler(); // key: allowWeakCrypto
|
||||
|
|
|
@ -86,6 +86,7 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({
|
|||
],
|
||||
"jsonStreamData": "how to handle streams in json output",
|
||||
"jsonStreamPrefix": "prefix for json stream data files",
|
||||
"toJson": "serialize to JSON",
|
||||
"allowWeakCrypto": "allow insecure cryptographic algorithms",
|
||||
"keepFilesOpen": "manage keeping multiple files open",
|
||||
"keepFilesOpenThreshold": "set threshold for keepFilesOpen",
|
||||
|
|
|
@ -3174,6 +3174,20 @@ Related Options
|
|||
:qpdf:ref:`--json-help` option to get a description of the JSON
|
||||
object.
|
||||
|
||||
.. qpdf:option:: --to-json
|
||||
|
||||
.. help: serialize to JSON
|
||||
|
||||
Shortcut for options useful for serializing PDF to JSON:
|
||||
--json=latest --json-stream-data=inline
|
||||
--json-key=qpdf --decode-level=none
|
||||
|
||||
This option is a shorthand for
|
||||
``--json=latest --json-stream-data=inline --json-key=qpdf --decode-level=none``.
|
||||
These are good options for serializing a PDF to JSON in manner that
|
||||
allows qpdf to read it back in. You can override any of these
|
||||
options by specifying other options after them.
|
||||
|
||||
.. qpdf:option:: --json-help
|
||||
|
||||
.. help: show format of JSON output
|
||||
|
|
|
@ -1111,7 +1111,7 @@ my @json_files = (
|
|||
['V4-aes', ['--json-key=encrypt']],
|
||||
['V4-aes', ['--json-key=encrypt', '--show-encryption-key']],
|
||||
);
|
||||
$n_tests += 24 + (2 * scalar(@json_files));
|
||||
$n_tests += 25 + (2 * scalar(@json_files));
|
||||
foreach my $d (@json_files)
|
||||
{
|
||||
my ($file, $xargs) = @$d;
|
||||
|
@ -1229,6 +1229,12 @@ foreach my $l (qw(none generalized specialized all))
|
|||
}
|
||||
}
|
||||
|
||||
$td->runtest("use --to-json option",
|
||||
{$td->COMMAND => "qpdf --to-json image-streams-small.pdf"},
|
||||
{$td->FILE => "image-streams-small-to-json.out",
|
||||
$td->EXIT_STATUS => 0},
|
||||
$td->NORMALIZE_NEWLINES);
|
||||
|
||||
show_ntests();
|
||||
# ----------
|
||||
$td->notify("--- Page API Tests ---");
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue