diff options
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDFJob.cc | 4 | ||||
-rw-r--r-- | libqpdf/QPDFJob_config.cc | 22 | ||||
-rw-r--r-- | libqpdf/qpdf/auto_job_help.hh | 7 | ||||
-rw-r--r-- | libqpdf/qpdf/auto_job_init.hh | 3 | ||||
-rw-r--r-- | libqpdf/qpdf/auto_job_json_init.hh | 3 |
5 files changed, 31 insertions, 8 deletions
diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc index 6a26d546..1c6a16d6 100644 --- a/libqpdf/QPDFJob.cc +++ b/libqpdf/QPDFJob.cc @@ -420,7 +420,7 @@ QPDFJob::Members::Members() : collate(0), flatten_rotation(false), list_attachments(false), - json(false), + json_version(0), check(false), optimize_images(false), externalize_inline_images(false), @@ -1924,7 +1924,7 @@ QPDFJob::doInspection(QPDF& pdf) { doCheck(pdf); } - if (m->json) + if (m->json_version) { doJSON(pdf); } diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc index b211b81c..2066e608 100644 --- a/libqpdf/QPDFJob_config.cc +++ b/libqpdf/QPDFJob_config.cc @@ -235,9 +235,27 @@ QPDFJob::Config::isEncrypted() } QPDFJob::Config* -QPDFJob::Config::json() +QPDFJob::Config::json(char const* parameter) { - o.m->json = true; + if (parameter) + { + if (strcmp(parameter, "latest") == 0) + { + o.m->json_version = 1; + } + else + { + o.m->json_version = QUtil::string_to_int(parameter); + } + } + else + { + o.m->json_version = 1; + } + if (o.m->json_version != 1) + { + usage(std::string("unsupported json version ") + parameter); + } o.m->require_outfile = false; return this; } diff --git a/libqpdf/qpdf/auto_job_help.hh b/libqpdf/qpdf/auto_job_help.hh index 18ce5a2b..ff497289 100644 --- a/libqpdf/qpdf/auto_job_help.hh +++ b/libqpdf/qpdf/auto_job_help.hh @@ -788,8 +788,11 @@ output as binary data. Get the key with --list-attachments. ap.addHelpTopic("json", "JSON output for PDF information", R"(Show information about the PDF file in JSON format. Please see the JSON chapter in the qpdf manual for details. )"); -ap.addOptionHelp("--json", "json", "show file in json format", R"(Generate a JSON representation of the file. This is described in -depth in the JSON section of the manual. +ap.addOptionHelp("--json", "json", "show file in json format", R"(--json[=version] + +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". )"); ap.addOptionHelp("--json-help", "json", "show format of json output", R"(Describe the format of the JSON output. )"); diff --git a/libqpdf/qpdf/auto_job_init.hh b/libqpdf/qpdf/auto_job_init.hh index 79fdc6d3..28c47be4 100644 --- a/libqpdf/qpdf/auto_job_init.hh +++ b/libqpdf/qpdf/auto_job_init.hh @@ -17,6 +17,7 @@ static char const* decode_level_choices[] = {"none", "generalized", "specialized static char const* object_streams_choices[] = {"disable", "preserve", "generate", 0}; static char const* remove_unref_choices[] = {"auto", "yes", "no", 0}; static char const* flatten_choices[] = {"all", "print", "screen", 0}; +static char const* json_version_choices[] = {"1", "latest", 0}; static char const* json_key_choices[] = {"acroform", "attachments", "encrypt", "objectinfo", "objects", "outlines", "pagelabels", "pages", 0}; static char const* print128_choices[] = {"full", "low", "none", 0}; static char const* modify128_choices[] = {"all", "annotate", "form", "assembly", "none", 0}; @@ -45,7 +46,6 @@ this->ap.addBare("flatten-rotation", [this](){c_main->flattenRotation();}); this->ap.addBare("generate-appearances", [this](){c_main->generateAppearances();}); this->ap.addBare("ignore-xref-streams", [this](){c_main->ignoreXrefStreams();}); this->ap.addBare("is-encrypted", [this](){c_main->isEncrypted();}); -this->ap.addBare("json", [this](){c_main->json();}); this->ap.addBare("keep-inline-images", [this](){c_main->keepInlineImages();}); this->ap.addBare("linearize", [this](){c_main->linearize();}); this->ap.addBare("list-attachments", [this](){c_main->listAttachments();}); @@ -110,6 +110,7 @@ this->ap.addChoices("object-streams", [this](char *x){c_main->objectStreams(x);} this->ap.addChoices("password-mode", [this](char *x){c_main->passwordMode(x);}, true, password_mode_choices); this->ap.addChoices("remove-unreferenced-resources", [this](char *x){c_main->removeUnreferencedResources(x);}, true, remove_unref_choices); this->ap.addChoices("stream-data", [this](char *x){c_main->streamData(x);}, true, stream_data_choices); +this->ap.addChoices("json", [this](char *x){c_main->json(x);}, false, json_version_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 39eb6437..df55d328 100644 --- a/libqpdf/qpdf/auto_job_json_init.hh +++ b/libqpdf/qpdf/auto_job_json_init.hh @@ -10,6 +10,7 @@ static char const* decode_level_choices[] = {"none", "generalized", "specialized static char const* object_streams_choices[] = {"disable", "preserve", "generate", 0}; static char const* remove_unref_choices[] = {"auto", "yes", "no", 0}; static char const* flatten_choices[] = {"all", "print", "screen", 0}; +static char const* json_version_choices[] = {"1", "latest", 0}; static char const* json_key_choices[] = {"acroform", "attachments", "encrypt", "objectinfo", "objects", "outlines", "pagelabels", "pages", 0}; static char const* print128_choices[] = {"full", "low", "none", 0}; static char const* modify128_choices[] = {"all", "annotate", "form", "assembly", "none", 0}; @@ -248,7 +249,7 @@ pushKey("showAttachment"); addParameter([this](char const* p) { c_main->showAttachment(p); }); popHandler(); // key: showAttachment pushKey("json"); -addBare([this]() { c_main->json(); }); +addChoices(json_version_choices, [this](char const* p) { c_main->json(p); }); popHandler(); // key: json pushKey("jsonKey"); beginArray(bindJSON(&Handlers::beginInspectJsonKeyArray), bindBare(&Handlers::endInspectJsonKeyArray)); // .inspect.jsonKey[] |