diff options
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDFJob_config.cc | 12 | ||||
-rw-r--r-- | libqpdf/qpdf/auto_job_help.hh | 11 | ||||
-rw-r--r-- | libqpdf/qpdf/auto_job_init.hh | 2 | ||||
-rw-r--r-- | libqpdf/qpdf/auto_job_json_init.hh | 2 |
4 files changed, 14 insertions, 13 deletions
diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc index ecdeafe3..6b72103b 100644 --- a/libqpdf/QPDFJob_config.cc +++ b/libqpdf/QPDFJob_config.cc @@ -295,14 +295,14 @@ QPDFJob::Config::jsonInput() QPDFJob::Config* QPDFJob::Config::jsonOutput(std::string const& parameter) { - std::string v = parameter; - if (parameter == "latest") { - v = "2"; + if (parameter.empty() || (parameter == "latest")) { + o.m->json_output = JSON::LATEST; + } else { + o.m->json_output = QUtil::string_to_int(parameter.c_str()); } - if (v != "2") { - usage("only version 2 is supported for --json-output"); + if ((o.m->json_output < 2) || (o.m->json_output > JSON::LATEST)) { + usage(std::string("unsupported json output version ") + parameter); } - o.m->json_output = QUtil::string_to_int(v.c_str()); if (!o.m->json_stream_data_set) { // No need to set json_stream_data_set -- that indicates // explicit use of --json-stream-data. diff --git a/libqpdf/qpdf/auto_job_help.hh b/libqpdf/qpdf/auto_job_help.hh index 7d88155b..e4bab551 100644 --- a/libqpdf/qpdf/auto_job_help.hh +++ b/libqpdf/qpdf/auto_job_help.hh @@ -795,8 +795,8 @@ ap.addOptionHelp("--json", "json", "show file in JSON format", R"(--json[=versio Generate a JSON representation of the file. This is described in 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. +specific version or "latest" (the default). Run qpdf --json-help +for a description of the generated JSON object. )"); 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 @@ -832,11 +832,12 @@ name as the prefix for stream data files. Whatever is given here will be appended with -nnn to create the name of the file that will contain the data for the stream stream in object nnn. )"); -ap.addOptionHelp("--json-output", "json", "serialize to JSON", R"(--json-output=version +ap.addOptionHelp("--json-output", "json", "serialize to JSON", R"(--json-output[=version] The output file will be qpdf JSON format at the given version. -Only version 2 is supported. See also --json-stream-data -and --json-stream-prefix +"version" may be a specific version or "latest" (the default). +Version 1 is not supported. See also --json-stream-data +and --json-stream-prefix. )"); ap.addOptionHelp("--json-input", "json", "input file is qpdf JSON", R"(Treat the input file as a JSON file in qpdf JSON format as written by qpdf --json-output. See the "QPDF JSON Format" diff --git a/libqpdf/qpdf/auto_job_init.hh b/libqpdf/qpdf/auto_job_init.hh index f582c6ec..c76a0b6a 100644 --- a/libqpdf/qpdf/auto_job_init.hh +++ b/libqpdf/qpdf/auto_job_init.hh @@ -112,7 +112,6 @@ this->ap.addChoices("compress-streams", [this](std::string const& x){c_main->com this->ap.addChoices("decode-level", [this](std::string const& x){c_main->decodeLevel(x);}, true, decode_level_choices); this->ap.addChoices("flatten-annotations", [this](std::string const& x){c_main->flattenAnnotations(x);}, true, flatten_choices); this->ap.addChoices("json-key", [this](std::string const& x){c_main->jsonKey(x);}, true, json_key_choices); -this->ap.addChoices("json-output", [this](std::string const& x){c_main->jsonOutput(x);}, true, json_output_choices); this->ap.addChoices("json-stream-data", [this](std::string const& x){c_main->jsonStreamData(x);}, true, json_stream_data_choices); this->ap.addChoices("keep-files-open", [this](std::string const& x){c_main->keepFilesOpen(x);}, true, yn_choices); this->ap.addChoices("normalize-content", [this](std::string const& x){c_main->normalizeContent(x);}, true, yn_choices); @@ -121,6 +120,7 @@ this->ap.addChoices("password-mode", [this](std::string const& x){c_main->passwo this->ap.addChoices("remove-unreferenced-resources", [this](std::string const& x){c_main->removeUnreferencedResources(x);}, true, remove_unref_choices); this->ap.addChoices("stream-data", [this](std::string const& x){c_main->streamData(x);}, true, stream_data_choices); this->ap.addChoices("json", [this](std::string const& x){c_main->json(x);}, false, json_version_choices); +this->ap.addChoices("json-output", [this](std::string const& x){c_main->jsonOutput(x);}, false, json_output_choices); this->ap.registerOptionTable("pages", b(&ArgParser::argEndPages)); this->ap.addPositional(p(&ArgParser::argPagesPositional)); this->ap.addRequiredParameter("password", p(&ArgParser::argPagesPassword), "password"); diff --git a/libqpdf/qpdf/auto_job_json_init.hh b/libqpdf/qpdf/auto_job_json_init.hh index 125250e6..168d5676 100644 --- a/libqpdf/qpdf/auto_job_json_init.hh +++ b/libqpdf/qpdf/auto_job_json_init.hh @@ -107,7 +107,7 @@ pushKey("splitPages"); addParameter([this](std::string const& p) { c_main->splitPages(p); }); popHandler(); // key: splitPages pushKey("jsonOutput"); -addChoices(json_output_choices, true, [this](std::string const& p) { c_main->jsonOutput(p); }); +addChoices(json_output_choices, false, [this](std::string const& p) { c_main->jsonOutput(p); }); popHandler(); // key: jsonOutput pushKey("encrypt"); beginDict(bindJSON(&Handlers::beginEncrypt), bindBare(&Handlers::endEncrypt)); // .encrypt |