Commit 27a42c16c790edb8d5998c541b7c271665359f61
1 parent
b0f15643
Change default decode level to "none" with --json-output
Showing
6 changed files
with
27 additions
and
17 deletions
job.sums
| ... | ... | @@ -8,10 +8,10 @@ include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c |
| 8 | 8 | include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1 |
| 9 | 9 | job.yml 3b2b3c6f92b48f6c76109711cbfdd74669fa31a80cd17379548b09f8e76be05d |
| 10 | 10 | libqpdf/qpdf/auto_job_decl.hh 74df4d7fdbdf51ecd0d58ce1e9844bb5525b9adac5a45f7c9a787ecdda2868df |
| 11 | -libqpdf/qpdf/auto_job_help.hh 3ea60a392421150bec5e95ddaad31a82fba1d65c2686d5dfddc920aba1bf5552 | |
| 11 | +libqpdf/qpdf/auto_job_help.hh c1cc99f6fe17285ee5e40730f6280e37d17da1a5f408086ce34e01af121df7ad | |
| 12 | 12 | libqpdf/qpdf/auto_job_init.hh 7ea8e0641dc26fdfba6e283e14dbbff0c016654e174cdace8054f8bef53750fd |
| 13 | 13 | libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297 |
| 14 | 14 | libqpdf/qpdf/auto_job_json_init.hh 5f6b53e3c81d4b54ce5c4cf9c3f52d0c02f987c53bf8841c0280367bad23e335 |
| 15 | 15 | libqpdf/qpdf/auto_job_schema.hh 9d543cd4a43eafffc2c4b8a6fee29e399c271c52cb6f7d417ae5497b3c1127dc |
| 16 | 16 | manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580 |
| 17 | -manual/cli.rst 174cf35e3ce5452701d74c87570604e19587cc41bfa3f6d239b62c2989720bdf | |
| 17 | +manual/cli.rst e7c35f8183d015d7fe074e38baed4c89bad827fd9c23b4cafd73d562df82ab1b | ... | ... |
libqpdf/QPDFJob_config.cc
| ... | ... | @@ -308,6 +308,9 @@ QPDFJob::Config::jsonOutput(std::string const& parameter) |
| 308 | 308 | // explicit use of --json-stream-data. |
| 309 | 309 | o.m->json_stream_data = qpdf_sj_inline; |
| 310 | 310 | } |
| 311 | + if (!o.m->decode_level_set) { | |
| 312 | + o.m->decode_level = qpdf_dl_none; | |
| 313 | + } | |
| 311 | 314 | return this; |
| 312 | 315 | } |
| 313 | 316 | ... | ... |
libqpdf/qpdf/auto_job_help.hh
| ... | ... | @@ -188,7 +188,7 @@ ap.addOptionHelp("--decode-level", "transformation", "control which streams to u |
| 188 | 188 | |
| 189 | 189 | When uncompressing streams, control which types of compression |
| 190 | 190 | schemes should be uncompressed: |
| 191 | -- none: don't uncompress anything | |
| 191 | +- none: don't uncompress anything. This is the default with --json-output. | |
| 192 | 192 | - generalized: uncompress streams compressed with a |
| 193 | 193 | general-purpose compression algorithm. This is the default. |
| 194 | 194 | - specialized: in addition to generalized, also uncompress |
| ... | ... | @@ -836,8 +836,8 @@ ap.addOptionHelp("--json-output", "json", "serialize to JSON", R"(--json-output[ |
| 836 | 836 | |
| 837 | 837 | The output file will be qpdf JSON format at the given version. |
| 838 | 838 | "version" may be a specific version or "latest" (the default). |
| 839 | -Version 1 is not supported. See also --json-stream-data | |
| 840 | -and --json-stream-prefix. | |
| 839 | +Version 1 is not supported. See also --json-stream-data, | |
| 840 | +--json-stream-prefix, and --decode-level. | |
| 841 | 841 | )"); |
| 842 | 842 | ap.addOptionHelp("--json-input", "json", "input file is qpdf JSON", R"(Treat the input file as a JSON file in qpdf JSON format as |
| 843 | 843 | written by qpdf --json-output. See the "QPDF JSON Format" | ... | ... |
manual/cli.rst
| ... | ... | @@ -852,7 +852,7 @@ Related Options |
| 852 | 852 | |
| 853 | 853 | When uncompressing streams, control which types of compression |
| 854 | 854 | schemes should be uncompressed: |
| 855 | - - none: don't uncompress anything | |
| 855 | + - none: don't uncompress anything. This is the default with --json-output. | |
| 856 | 856 | - generalized: uncompress streams compressed with a |
| 857 | 857 | general-purpose compression algorithm. This is the default. |
| 858 | 858 | - specialized: in addition to generalized, also uncompress |
| ... | ... | @@ -867,14 +867,15 @@ Related Options |
| 867 | 867 | |
| 868 | 868 | The following values for :samp:`{parameter}` are available: |
| 869 | 869 | |
| 870 | - - :samp:`none`: do not attempt to decode any streams | |
| 870 | + - :samp:`none`: do not attempt to decode any streams. This is the | |
| 871 | + default with :qpdf:ref:`--json-output`. | |
| 871 | 872 | |
| 872 | 873 | - :samp:`generalized`: decode streams filtered with supported |
| 873 | 874 | generalized filters: ``/LZWDecode``, ``/FlateDecode``, |
| 874 | 875 | ``/ASCII85Decode``, and ``/ASCIIHexDecode``. We define |
| 875 | 876 | generalized filters as those to be used for general-purpose |
| 876 | 877 | compression or encoding, as opposed to filters specifically |
| 877 | - designed for image data. | |
| 878 | + designed for image data. This is the default. | |
| 878 | 879 | |
| 879 | 880 | - :samp:`specialized`: in addition to generalized, decode streams |
| 880 | 881 | with supported non-lossy specialized filters; currently this is |
| ... | ... | @@ -896,7 +897,9 @@ Related Options |
| 896 | 897 | qpdf will recompress streams with generalized filters using flate |
| 897 | 898 | compression, effectively eliminating LZW and ASCII-based filters. |
| 898 | 899 | This is usually desirable behavior but can be disabled with |
| 899 | - ``--decode-level=none``. | |
| 900 | + ``--decode-level=none``. Note that ``--decode-level=node`` is the | |
| 901 | + default when :qpdf:ref:`--json-output` is specified, but it can be | |
| 902 | + overridden in that case as well. | |
| 900 | 903 | |
| 901 | 904 | As a special case, streams already compressed with ``/FlateDecode`` |
| 902 | 905 | are not uncompressed and recompressed. You can change this behavior |
| ... | ... | @@ -3264,13 +3267,18 @@ Related Options |
| 3264 | 3267 | |
| 3265 | 3268 | The output file will be qpdf JSON format at the given version. |
| 3266 | 3269 | "version" may be a specific version or "latest" (the default). |
| 3267 | - Version 1 is not supported. See also --json-stream-data | |
| 3268 | - and --json-stream-prefix. | |
| 3270 | + Version 1 is not supported. See also --json-stream-data, | |
| 3271 | + --json-stream-prefix, and --decode-level. | |
| 3269 | 3272 | |
| 3270 | 3273 | The output file will be qpdf JSON format at the given version. |
| 3271 | 3274 | ``version`` may be a specific version or ``latest`` (the default). |
| 3272 | 3275 | Version 1 is not supported. See also :qpdf:ref:`--json-stream-data` |
| 3273 | - and :qpdf:ref:`--json-stream-prefix`. | |
| 3276 | + and :qpdf:ref:`--json-stream-prefix`. The default decode level is | |
| 3277 | + ``none``, but you can override it with :qpdf:ref:`--decode-level`. | |
| 3278 | + If you want to look at the contents of streams easily as you would | |
| 3279 | + in QDF mode (see :ref:`qdf`), you can use | |
| 3280 | + ``--decode-level=generalized`` and ``--json-stream-data=file`` for | |
| 3281 | + a convenient way to do that. | |
| 3274 | 3282 | |
| 3275 | 3283 | .. qpdf:option:: --json-input |
| 3276 | 3284 | ... | ... |
qpdf/qtest/json.test
| ... | ... | @@ -69,7 +69,7 @@ foreach my $d (@json_files) |
| 69 | 69 | |
| 70 | 70 | $td->runtest("bad json stream data (inline)", |
| 71 | 71 | {$td->COMMAND => |
| 72 | - "qpdf --json-output=2" . | |
| 72 | + "qpdf --json-output=2 --decode-level=all" . | |
| 73 | 73 | " --json-stream-data=inline bad-data.pdf a.json"}, |
| 74 | 74 | {$td->FILE => "bad-data-json.out", $td->EXIT_STATUS => 3}, |
| 75 | 75 | $td->NORMALIZE_NEWLINES); |
| ... | ... | @@ -79,7 +79,7 @@ $td->runtest("check (inline)", |
| 79 | 79 | $td->NORMALIZE_NEWLINES); |
| 80 | 80 | $td->runtest("bad json stream data (file)", |
| 81 | 81 | {$td->COMMAND => |
| 82 | - "qpdf --json-output=2 " . | |
| 82 | + "qpdf --json-output=2 --decode-level=all" . | |
| 83 | 83 | " --json-stream-data=file --json-stream-prefix=auto" . |
| 84 | 84 | " bad-data.pdf a.json"}, |
| 85 | 85 | {$td->FILE => "bad-data-json.out", $td->EXIT_STATUS => 3}, | ... | ... |
qpdf/qtest/qpdf-json.test
| ... | ... | @@ -71,15 +71,14 @@ foreach my $i (@goodfiles) |
| 71 | 71 | } |
| 72 | 72 | # explicit "latest" as --json-output version |
| 73 | 73 | $td->runtest("good: $f -> JSON", |
| 74 | - {$td->COMMAND => "qpdf $xargs --decode-level=none" . | |
| 74 | + {$td->COMMAND => "qpdf $xargs" . | |
| 75 | 75 | " --json-output=latest $f a.json"}, |
| 76 | 76 | {$td->STRING => "", $td->EXIT_STATUS => 0}, |
| 77 | 77 | $td->NORMALIZE_NEWLINES); |
| 78 | 78 | # default --json-output version |
| 79 | 79 | $td->runtest("good: $f JSON -> JSON", |
| 80 | 80 | {$td->COMMAND => |
| 81 | - "qpdf --decode-level=none" . | |
| 82 | - " --json-input --json-output a.json b.json"}, | |
| 81 | + "qpdf --json-input --json-output a.json b.json"}, | |
| 83 | 82 | {$td->STRING => "", $td->EXIT_STATUS => 0}, |
| 84 | 83 | $td->NORMALIZE_NEWLINES); |
| 85 | 84 | $td->runtest("good: $f JSON -> QDF", | ... | ... |