Commit c0c7cef16cb666524e4809834063cfee5262eca1

Authored by Jay Berkenbilt
1 parent 1f456868

Generate a UNIX man page (fixes #874)

CMakeLists.txt
... ... @@ -4,7 +4,8 @@ cmake_minimum_required(VERSION 3.16)
4 4 # make_dist expects the version line to be on a line by itself after
5 5 # the project line. When updating the version, check make_dist for all
6 6 # the places it has to be updated. The doc configuration and CI build
7   -# also find the version number here.
  7 +# also find the version number here. generate_auto_job also reads the
  8 +# version from here.
8 9 project(qpdf
9 10 VERSION 11.7.0
10 11 LANGUAGES C CXX)
... ... @@ -312,9 +313,12 @@ endif()
312 313 set(auto_job_inputs
313 314 # Keep in sync with SOURCES in generate_auto_job
314 315 generate_auto_job
  316 + CMakeLists.txt
315 317 manual/_ext/qpdf.py
316 318 job.yml
317   - manual/cli.rst)
  319 + manual/cli.rst
  320 + manual/qpdf.1.in
  321 +)
318 322  
319 323 set(auto_job_outputs
320 324 # Keep in sync with DESTS in generate_auto_job
... ... @@ -323,7 +327,9 @@ set(auto_job_outputs
323 327 libqpdf/qpdf/auto_job_help.hh
324 328 libqpdf/qpdf/auto_job_schema.hh
325 329 libqpdf/qpdf/auto_job_json_decl.hh
326   - libqpdf/qpdf/auto_job_json_init.hh)
  330 + libqpdf/qpdf/auto_job_json_init.hh
  331 + manual/qpdf.1
  332 +)
327 333  
328 334 if(GENERATE_AUTO_JOB)
329 335 add_custom_command(
... ...
ChangeLog
1 1 2023-12-22 Jay Berkenbilt <ejb@ql.org>
2 2  
  3 + * Generate a more complete qpdf "man page" from the same source as
  4 + qpdf --help. Fixes #874.
  5 +
3 6 * Allow the syntax "--encrypt --user-password=user-password
4 7 --owner-password=owner-password --bits={40,128,256}" when
5 8 encrypting PDF files. This is an alternative to the syntax
... ...
generate_auto_job
... ... @@ -134,6 +134,12 @@ BANNER = f&#39;&#39;&#39;//
134 134 // clang-format off
135 135 //'''
136 136  
  137 +MAN_BANNER = f'''.\\"
  138 +.\\" This file is automatically generated by {whoami}.
  139 +.\\" Edits will be automatically overwritten if the build is
  140 +.\\" run in maintainer mode.
  141 +.\\"
  142 +'''
137 143  
138 144 def warn(*args, **kwargs):
139 145 print(*args, file=sys.stderr, **kwargs)
... ... @@ -156,9 +162,11 @@ class Main:
156 162 SOURCES = [
157 163 # Keep this list in sync with CMakeLists.txt: auto_job_inputs
158 164 whoami,
  165 + 'CMakeLists.txt',
159 166 'manual/_ext/qpdf.py',
160 167 'job.yml',
161 168 'manual/cli.rst',
  169 + 'manual/qpdf.1.in',
162 170 ]
163 171 # DESTS is a map to the output files this code generates. These
164 172 # generated files, as well as those added to DESTS later in the
... ... @@ -172,6 +180,7 @@ class Main:
172 180 'schema': 'libqpdf/qpdf/auto_job_schema.hh',
173 181 'json_decl': 'libqpdf/qpdf/auto_job_json_decl.hh',
174 182 'json_init': 'libqpdf/qpdf/auto_job_json_init.hh',
  183 + 'man': 'manual/qpdf.1',
175 184 # Others are added in top
176 185 }
177 186 # SUMS contains a checksum for each source and destination and is
... ... @@ -277,7 +286,7 @@ class Main:
277 286 for k, v in hashes.items():
278 287 print(f'{k} {v}', file=f)
279 288  
280   - def generate_doc(self, df, f):
  289 + def generate_doc(self, df, f, f_man):
281 290 st_top = 0
282 291 st_topic = 1
283 292 st_option = 2
... ... @@ -324,6 +333,23 @@ class Main:
324 333 return True
325 334 return False
326 335  
  336 + def manify(text):
  337 + lines = text.split('\n')
  338 + out = []
  339 + last_was_item = False
  340 + for line in lines:
  341 + if line.startswith('- '):
  342 + last_was_item = True
  343 + out.append('.IP \\[bu]')
  344 + out.append(line[2:])
  345 + elif last_was_item and line.startswith(' '):
  346 + out.append(line[2:])
  347 + else:
  348 + last_was_item = False
  349 + out.append(line)
  350 + return '\n'.join(out)
  351 +
  352 + last_option_topic = ''
327 353 lineno = 0
328 354 for line in df.readlines():
329 355 if help_lines == 0:
... ... @@ -366,6 +392,8 @@ class Main:
366 392 self.all_topics.add(topic)
367 393 print(f'ap.addHelpTopic("{topic}", "{short_text}",'
368 394 f' R"({long_text})");', file=f)
  395 + print(f'.SH {topic.upper()} ({short_text})', file=f_man)
  396 + print(manify(long_text), file=f_man, end='')
369 397 help_lines += 1
370 398 state = st_top
371 399 elif state == st_option:
... ... @@ -389,6 +417,11 @@ class Main:
389 417 self.jdata[option[2:]]['help'] = short_text
390 418 print(f'ap.addOptionHelp("{option}", "{topic}",'
391 419 f' "{short_text}", R"({long_text})");', file=f)
  420 + if last_option_topic != topic:
  421 + print('.PP\nRelated Options:', file=f_man)
  422 + last_option_topic = topic
  423 + print(f'.TP\n.B {option} \\-\\- {short_text}', file=f_man)
  424 + print(manify(long_text), file=f_man, end='')
392 425 help_lines += 1
393 426 state = st_top
394 427 if help_lines == 20:
... ... @@ -400,6 +433,11 @@ class Main:
400 433 print('ap.addHelpFooter("For detailed help, visit'
401 434 ' the qpdf manual: https://qpdf.readthedocs.io\\n");', file=f)
402 435 print('}\n', file=f)
  436 + print('''.SH SEE ALSO
  437 +.PP
  438 +For a summary of qpdf's options, please run \\fBqpdf \\-\\-help\\fR.
  439 +A complete manual can be found at https://qpdf.readthedocs.io.
  440 +''', file=f_man, end='')
403 441 for i in self.referenced_topics:
404 442 if i not in self.all_topics:
405 443 raise Exception(f'help text referenced --help={i}')
... ... @@ -412,6 +450,14 @@ class Main:
412 450 warn(f'{whoami}: regenerating auto job files')
413 451 self.validate(data)
414 452  
  453 + version = None
  454 + with open('CMakeLists.txt', 'r') as f:
  455 + for line in f.readlines():
  456 + if line.strip().startswith('VERSION '):
  457 + version = line.strip().split(' ')[1]
  458 + if version is None:
  459 + raise Exception("can't read version from CMakeLists.txt")
  460 +
415 461 # Keep track of which options are help options since they are
416 462 # handled specially. Add the built-in help options to tables
417 463 # that we populate as we read job.yml since we won't encounter
... ... @@ -436,9 +482,15 @@ class Main:
436 482 for i in self.init:
437 483 print(i, file=f)
438 484 with write_file(self.DESTS['help']) as f:
439   - with open('manual/cli.rst', 'r') as df:
440   - print(BANNER, file=f)
441   - self.generate_doc(df, f)
  485 + with write_file(self.DESTS['man']) as f_man:
  486 + print(MAN_BANNER, file=f_man, end='')
  487 + with open('manual/qpdf.1.in', 'r') as m_in:
  488 + for line in m_in.readlines():
  489 + line = line.replace('@PROJECT_VERSION@', version)
  490 + print(line, file=f_man, end='')
  491 + with open('manual/cli.rst', 'r') as df:
  492 + print(BANNER, file=f)
  493 + self.generate_doc(df, f, f_man)
442 494  
443 495 # Compute the json files after the config and arg parsing
444 496 # files. We need to have full information about all the
... ...
job.sums
1 1 # Generated by generate_auto_job
2   -generate_auto_job bf44181b610d335511a41b6c2b9c3497d0b023a1ca2c8e4537b34cb6262ce173
  2 +CMakeLists.txt 66e8f9bf15a0c3394b1b13baaf5a709f7af35a6f733cd173092168e87202c7a5
  3 +generate_auto_job f64733b79dcee5a0e3e8ccc6976448e8ddf0e8b6529987a66a7d3ab2ebc10a86
3 4 include/qpdf/auto_job_c_att.hh 4c2b171ea00531db54720bf49a43f8b34481586ae7fb6cbf225099ee42bc5bb4
4 5 include/qpdf/auto_job_c_copy_att.hh 50609012bff14fd82f0649185940d617d05d530cdc522185c7f3920a561ccb42
5 6 include/qpdf/auto_job_c_enc.hh 28446f3c32153a52afa239ea40503e6cc8ac2c026813526a349e0cd4ae17ddd5
... ... @@ -8,10 +9,12 @@ include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c
8 9 include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1
9 10 job.yml 4f89fc7b622df897d30d403d8035aa36fc7de8d8c43042c736e0300d904cb05c
10 11 libqpdf/qpdf/auto_job_decl.hh 9c6f701c29f3f764d620186bed92685a2edf2e4d11e4f4532862c05470cfc4d2
11   -libqpdf/qpdf/auto_job_help.hh ea1fdca2aa405bdf193732c5a2789c602efe2add3aa6e2dceecfacee175ce65c
  12 +libqpdf/qpdf/auto_job_help.hh bbd37ac0e8b3e38892a328ca08829d6e71c31ea3ab6c1a91b5f6983018695ef9
12 13 libqpdf/qpdf/auto_job_init.hh b4c2b3724fba61f1206fd3bae81951636852592f67a63ef9539839c2c5995065
13 14 libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297
14 15 libqpdf/qpdf/auto_job_json_init.hh f5acb9aa103131cb68dec0e12c4d237a6459bdb49b24773c24f0c2724a462b8f
15 16 libqpdf/qpdf/auto_job_schema.hh b53c006fec2e75b1b73588d242d49a32f7d3db820b1541de106c5d4c27fbb4d9
16 17 manual/_ext/qpdf.py 6add6321666031d55ed4aedf7c00e5662bba856dfcd66ccb526563bffefbb580
17   -manual/cli.rst 28cc6b36b26377404022bab467e6a16085023fdfa5d9d419595ffcae6c69d531
  18 +manual/cli.rst 7bbeb2f234ca3d095c069f52e4a3c5e42a525b5ef6231955d036a6313eaffcd2
  19 +manual/qpdf.1 745cb32c1772e6d84ef962aca7a439ee045226ae547330778a4a3ba3cd8d25df
  20 +manual/qpdf.1.in 436ecc85d45c4c9e2dbd1725fb7f0177fb627179469f114561adf3cb6cbb677b
... ...
libqpdf/qpdf/auto_job_help.hh
... ... @@ -37,10 +37,10 @@ description of the JSON input file format.
37 37 )");
38 38 ap.addHelpTopic("exit-status", "meanings of qpdf's exit codes", R"(Meaning of exit codes:
39 39  
40   -0: no errors or warnings
41   -1: not used by qpdf but may be used by the shell if unable to invoke qpdf
42   -2: errors detected
43   -3: warnings detected, unless --warning-exit-0 is given
  40 +- 0: no errors or warnings
  41 +- 1: not used by qpdf but may be used by the shell if unable to invoke qpdf
  42 +- 2: errors detected
  43 +- 3: warnings detected, unless --warning-exit-0 is given
44 44 )");
45 45 ap.addOptionHelp("--warning-exit-0", "exit-status", "exit 0 even with warnings", R"(Use exit status 0 instead of 3 when warnings are present. When
46 46 combined with --no-warn, warnings are completely ignored.
... ...
manual/CMakeLists.txt
... ... @@ -22,7 +22,7 @@ if(BUILD_DOC)
22 22 endif()
23 23  
24 24 set(MANUAL_SRC ${qpdf_SOURCE_DIR}/manual)
25   -foreach(F qpdf.1 fix-qdf.1 zlib-flate.1)
  25 +foreach(F fix-qdf.1 zlib-flate.1)
26 26 configure_file(
27 27 ${MANUAL_SRC}/${F}.in
28 28 ${CMAKE_CURRENT_BINARY_DIR}/${F}
... ... @@ -129,7 +129,7 @@ if(NOT WIN32)
129 129 # environment, especially when all they do is refer people to the
130 130 # manual.
131 131 install(FILES
132   - ${CMAKE_CURRENT_BINARY_DIR}/qpdf.1
  132 + ${qpdf_SOURCE_DIR}/manual/qpdf.1
133 133 ${CMAKE_CURRENT_BINARY_DIR}/fix-qdf.1
134 134 ${CMAKE_CURRENT_BINARY_DIR}/zlib-flate.1
135 135 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
... ...
manual/cli.rst
... ... @@ -184,10 +184,10 @@ Exit Status
184 184  
185 185 Meaning of exit codes:
186 186  
187   - 0: no errors or warnings
188   - 1: not used by qpdf but may be used by the shell if unable to invoke qpdf
189   - 2: errors detected
190   - 3: warnings detected, unless --warning-exit-0 is given
  187 + - 0: no errors or warnings
  188 + - 1: not used by qpdf but may be used by the shell if unable to invoke qpdf
  189 + - 2: errors detected
  190 + - 3: warnings detected, unless --warning-exit-0 is given
191 191  
192 192 The exit status of :command:`qpdf` may be interpreted as follows:
193 193  
... ...
manual/qpdf.1 0 โ†’ 100644
  1 +.\"
  2 +.\" This file is automatically generated by generate_auto_job.
  3 +.\" Edits will be automatically overwritten if the build is
  4 +.\" run in maintainer mode.
  5 +.\"
  6 +.TH QPDF "1" "" "qpdf version 11.7.0" "User Commands"
  7 +.SH NAME
  8 +qpdf \- PDF transformation software
  9 +.SH SYNOPSIS
  10 +.B qpdf
  11 +.RI "[ " options " ] " infilename " [ " outfilename " ]"
  12 +.SH DESCRIPTION
  13 +The qpdf program is used to convert one PDF file to another equivalent
  14 +PDF file. It is capable of performing a variety of transformations
  15 +such as linearization (also known as web optimization or fast web
  16 +viewing), encryption, and decryption of PDF files. It also has many
  17 +options for inspecting or checking PDF files, some of which are
  18 +useful primarily to PDF developers.
  19 +.PP
  20 +For a summary of qpdf's options, please run \fBqpdf \-\-help\fR. A
  21 +complete manual can be found at https://qpdf.readthedocs.io.
  22 +.SH USAGE (basic invocation)
  23 +Read a PDF file, apply transformations or modifications, and write
  24 +a new PDF file.
  25 +
  26 +Usage: qpdf [infile] [options] [outfile]
  27 + OR qpdf --help[={topic|--option}]
  28 +
  29 +.IP \[bu]
  30 +infile, options, and outfile may be in any order as long as infile
  31 +precedes outfile.
  32 +.IP \[bu]
  33 +Use --empty in place of an input file for a zero-page, empty input
  34 +.IP \[bu]
  35 +Use --replace-input in place of an output file to overwrite the
  36 +input file with the output
  37 +.IP \[bu]
  38 +outfile may be - to write to stdout; reading from stdin is not supported
  39 +.IP \[bu]
  40 +@filename is an argument file; each line is treated as a separate
  41 +command-line argument
  42 +.IP \[bu]
  43 +@- may be used to read arguments from stdin
  44 +.IP \[bu]
  45 +Later options may override earlier options if contradictory
  46 +.PP
  47 +Related Options:
  48 +.TP
  49 +.B --empty \-\- use empty file as input
  50 +Use in place of infile for an empty input. Especially useful
  51 +with --pages.
  52 +.TP
  53 +.B --replace-input \-\- overwrite input with output
  54 +Use in place of outfile to overwrite the input file with the output.
  55 +.TP
  56 +.B --job-json-file \-\- job JSON file
  57 +--job-json-file=file
  58 +
  59 +Specify the name of a file whose contents are expected to
  60 +contain a QPDFJob JSON file. Run qpdf --job-json-help for a
  61 +description of the JSON input file format.
  62 +.SH EXIT-STATUS (meanings of qpdf's exit codes)
  63 +Meaning of exit codes:
  64 +
  65 +.IP \[bu]
  66 +0: no errors or warnings
  67 +.IP \[bu]
  68 +1: not used by qpdf but may be used by the shell if unable to invoke qpdf
  69 +.IP \[bu]
  70 +2: errors detected
  71 +.IP \[bu]
  72 +3: warnings detected, unless --warning-exit-0 is given
  73 +.PP
  74 +Related Options:
  75 +.TP
  76 +.B --warning-exit-0 \-\- exit 0 even with warnings
  77 +Use exit status 0 instead of 3 when warnings are present. When
  78 +combined with --no-warn, warnings are completely ignored.
  79 +.SH COMPLETION (shell completion)
  80 +Shell completion is supported with bash and zsh. Use
  81 +eval $(qpdf --completion-bash) or eval $(qpdf --completion-zsh)
  82 +to enable. The QPDF_EXECUTABLE environment variable overrides the
  83 +path to qpdf that these commands output.
  84 +.PP
  85 +Related Options:
  86 +.TP
  87 +.B --completion-bash \-\- enable bash completion
  88 +Output a command that enables bash completion
  89 +.TP
  90 +.B --completion-zsh \-\- enable zsh completion
  91 +Output a command that enables zsh completion
  92 +.SH HELP (information about qpdf)
  93 +Help options provide some information about qpdf itself. Help
  94 +options are only valid as the first and only command-line argument.
  95 +.PP
  96 +Related Options:
  97 +.TP
  98 +.B --help \-\- provide help
  99 +--help[=--option|topic]
  100 +
  101 +--help: provide general information and a list of topics
  102 +--help=--option: provide help on a specific option
  103 +--help=topic: provide help on a topic
  104 +.TP
  105 +.B --version \-\- show qpdf version
  106 +Display the version of qpdf.
  107 +.TP
  108 +.B --copyright \-\- show copyright information
  109 +Display copyright and license information.
  110 +.TP
  111 +.B --show-crypto \-\- show available crypto providers
  112 +Show a list of available crypto providers, one per line. The
  113 +default provider is shown first.
  114 +.TP
  115 +.B --job-json-help \-\- show format of job JSON
  116 +Describe the format of the QPDFJob JSON input used by
  117 +--job-json-file.
  118 +.SH GENERAL (general options)
  119 +General options control qpdf's behavior in ways that are not
  120 +directly related to the operation it is performing.
  121 +.PP
  122 +Related Options:
  123 +.TP
  124 +.B --password \-\- password for encrypted file
  125 +--password=password
  126 +
  127 +Specify a password for an encrypted, password-protected file.
  128 +Not needed for encrypted files without a password.
  129 +.TP
  130 +.B --password-file \-\- read password from a file
  131 +--password-file=filename
  132 +
  133 +The first line of the specified file is used as the password.
  134 +This is used in place of the --password option.
  135 +.TP
  136 +.B --verbose \-\- print additional information
  137 +Output additional information about various things qpdf is
  138 +doing, including information about files created and operations
  139 +performed.
  140 +.TP
  141 +.B --progress \-\- show progress when writing
  142 +Indicate progress when writing files.
  143 +.TP
  144 +.B --no-warn \-\- suppress printing of warning messages
  145 +Suppress printing of warning messages. If warnings were
  146 +encountered, qpdf still exits with exit status 3.
  147 +Use --warning-exit-0 with --no-warn to completely ignore
  148 +warnings.
  149 +.TP
  150 +.B --deterministic-id \-\- generate ID deterministically
  151 +Generate a secure, random document ID only using static
  152 +information, such as the page contents. Does not use the file's
  153 +name or attributes or the current time.
  154 +.TP
  155 +.B --allow-weak-crypto \-\- allow insecure cryptographic algorithms
  156 +Allow creation of files with weak cryptographic algorithms. This
  157 +option is necessary to create 40-bit files or 128-bit files that
  158 +use RC4 encryption.
  159 +.TP
  160 +.B --keep-files-open \-\- manage keeping multiple files open
  161 +--keep-files-open=[y|n]
  162 +
  163 +When qpdf needs to work with many files, as when merging large
  164 +numbers of files, explicitly indicate whether files should be
  165 +kept open. The default behavior is to determine this based on
  166 +the number of files.
  167 +.TP
  168 +.B --keep-files-open-threshold \-\- set threshold for --keep-files-open
  169 +--keep-files-open-threshold=count
  170 +
  171 +Set the threshold used by --keep-files-open, overriding the
  172 +default value of 200.
  173 +.SH ADVANCED-CONTROL (tweak qpdf's behavior)
  174 +Advanced control options control qpdf's behavior in ways that would
  175 +normally never be needed by a user but that may be useful to
  176 +developers or people investigating problems with specific files.
  177 +.PP
  178 +Related Options:
  179 +.TP
  180 +.B --password-is-hex-key \-\- provide hex-encoded encryption key
  181 +Provide the underlying file encryption key as a hex-encoded
  182 +string rather than supplying a password. This is an expert
  183 +option.
  184 +.TP
  185 +.B --suppress-password-recovery \-\- don't try different password encodings
  186 +Suppress qpdf's usual behavior of attempting different encodings
  187 +of a password that contains non-ASCII Unicode characters if the
  188 +first attempt doesn't succeed.
  189 +.TP
  190 +.B --password-mode \-\- tweak how qpdf encodes passwords
  191 +--password-mode=mode
  192 +
  193 +Fine-tune how qpdf controls encoding of Unicode passwords. Valid
  194 +options are auto, bytes, hex-bytes, and unicode.
  195 +.TP
  196 +.B --suppress-recovery \-\- suppress error recovery
  197 +Avoid attempting to recover when errors are found in a file's
  198 +cross reference table or stream lengths.
  199 +.TP
  200 +.B --ignore-xref-streams \-\- use xref tables rather than streams
  201 +Ignore any cross-reference streams in the file, falling back to
  202 +cross-reference tables or triggering document recovery.
  203 +.SH TRANSFORMATION (make structural PDF changes)
  204 +The options below tell qpdf to apply transformations that change
  205 +the structure without changing the content.
  206 +.PP
  207 +Related Options:
  208 +.TP
  209 +.B --linearize \-\- linearize (web-optimize) output
  210 +Create linearized (web-optimized) output files.
  211 +.TP
  212 +.B --encrypt \-\- start encryption options
  213 +--encrypt [options] --
  214 +
  215 +Run qpdf --help=encryption for details.
  216 +.TP
  217 +.B --decrypt \-\- remove encryption from input file
  218 +Create an unencrypted output file even if the input file was
  219 +encrypted. Normally qpdf preserves whatever encryption was
  220 +present on the input file. This option overrides that behavior.
  221 +.TP
  222 +.B --remove-restrictions \-\- remove security restrictions from input file
  223 +Remove restrictions associated with digitally signed PDF files.
  224 +This may be combined with --decrypt to allow free editing of
  225 +previously signed/encrypted files. This option invalidates the
  226 +signature but leaves its visual appearance intact.
  227 +.TP
  228 +.B --copy-encryption \-\- copy another file's encryption details
  229 +--copy-encryption=file
  230 +
  231 +Copy encryption details from the specified file instead of
  232 +preserving the input file's encryption. Use --encryption-file-password
  233 +to specify the encryption file's password.
  234 +.TP
  235 +.B --encryption-file-password \-\- supply password for --copy-encryption
  236 +--encryption-file-password=password
  237 +
  238 +If the file named in --copy-encryption requires a password, use
  239 +this option to supply the password.
  240 +.TP
  241 +.B --qdf \-\- enable viewing PDF code in a text editor
  242 +Create a PDF file suitable for viewing in a text editor and even
  243 +editing. This is for editing the PDF code, not the page contents.
  244 +All streams that can be uncompressed are uncompressed, and
  245 +content streams are normalized, among other changes. The
  246 +companion tool "fix-qdf" can be used to repair hand-edited QDF
  247 +files. QDF is a feature specific to the qpdf tool. Please see
  248 +the "QDF Mode" chapter in the manual.
  249 +.TP
  250 +.B --no-original-object-ids \-\- omit original object IDs in qdf
  251 +Omit comments in a QDF file indicating the object ID an object
  252 +had in the original file.
  253 +.TP
  254 +.B --compress-streams \-\- compress uncompressed streams
  255 +--compress-streams=[y|n]
  256 +
  257 +Setting --compress-streams=n prevents qpdf from compressing
  258 +uncompressed streams. This can be useful if you are leaving some
  259 +streams uncompressed intentionally.
  260 +.TP
  261 +.B --decode-level \-\- control which streams to uncompress
  262 +--decode-level=parameter
  263 +
  264 +When uncompressing streams, control which types of compression
  265 +schemes should be uncompressed:
  266 +.IP \[bu]
  267 +none: don't uncompress anything. This is the default with
  268 +--json-output.
  269 +.IP \[bu]
  270 +generalized: uncompress streams compressed with a
  271 +general-purpose compression algorithm. This is the default
  272 +except when --json-output is given.
  273 +.IP \[bu]
  274 +specialized: in addition to generalized, also uncompress
  275 +streams compressed with a special-purpose but non-lossy
  276 +compression scheme
  277 +.IP \[bu]
  278 +all: in addition to specialized, uncompress streams compressed
  279 +with lossy compression schemes like JPEG (DCT)
  280 +qpdf does not know how to uncompress all compression schemes.
  281 +.TP
  282 +.B --stream-data \-\- control stream compression
  283 +--stream-data=parameter
  284 +
  285 +This option controls how streams are compressed in the output.
  286 +It is less granular than the newer options, --compress-streams
  287 +and --decode-level.
  288 +
  289 +Parameters:
  290 +.IP \[bu]
  291 +compress: same as --compress-streams=y --decode-level=generalized
  292 +.IP \[bu]
  293 +preserve: same as --compress-streams=n --decode-level=none
  294 +.IP \[bu]
  295 +uncompress: same as --compress-streams=n --decode-level=generalized
  296 +.TP
  297 +.B --recompress-flate \-\- uncompress and recompress flate
  298 +The default generalized compression scheme used by PDF is flate,
  299 +which is the same as used by zip and gzip. Usually qpdf just
  300 +leaves these alone. This option tells qpdf to uncompress and
  301 +recompress streams compressed with flate. This can be useful
  302 +when combined with --compression-level.
  303 +.TP
  304 +.B --compression-level \-\- set compression level for flate
  305 +--compression-level=level
  306 +
  307 +Set a compression level from 1 (least, fastest) to 9 (most,
  308 +slowest) when compressing files with flate (used in zip and
  309 +gzip), which is the default compression for most PDF files.
  310 +You need --recompress-flate with this option if you want to
  311 +change already compressed streams.
  312 +.TP
  313 +.B --normalize-content \-\- fix newlines in content streams
  314 +--normalize-content=[y|n]
  315 +
  316 +Normalize newlines to UNIX-style newlines in PDF content
  317 +streams, which is useful for viewing them in a programmer's text
  318 +editor across multiple platforms. This is also turned on by
  319 +--qdf.
  320 +.TP
  321 +.B --object-streams \-\- control use of object streams
  322 +--object-streams=mode
  323 +
  324 +Control what qpdf does regarding object streams. Options:
  325 +.IP \[bu]
  326 +preserve: preserve original object streams, if any (the default)
  327 +.IP \[bu]
  328 +disable: create output files with no object streams
  329 +.IP \[bu]
  330 +generate: create object streams, and compress objects when possible
  331 +.TP
  332 +.B --preserve-unreferenced \-\- preserve unreferenced objects
  333 +Preserve all objects from the input even if not referenced.
  334 +.TP
  335 +.B --remove-unreferenced-resources \-\- remove unreferenced page resources
  336 +--remove-unreferenced-resources=parameter
  337 +
  338 +Remove from a page's resource dictionary any resources that are
  339 +not referenced in the page's contents. Parameters: "auto"
  340 +(default), "yes", "no".
  341 +.TP
  342 +.B --preserve-unreferenced-resources \-\- use --remove-unreferenced-resources=no
  343 +Synonym for --remove-unreferenced-resources=no. Use that instead.
  344 +.TP
  345 +.B --newline-before-endstream \-\- force a newline before endstream
  346 +For an extra newline before endstream. Using this option enables
  347 +qpdf to preserve PDF/A when rewriting such files.
  348 +.TP
  349 +.B --coalesce-contents \-\- combine content streams
  350 +If a page has an array of content streams, concatenate them into
  351 +a single content stream.
  352 +.TP
  353 +.B --externalize-inline-images \-\- convert inline to regular images
  354 +Convert inline images to regular images.
  355 +.TP
  356 +.B --ii-min-bytes \-\- set minimum size for --externalize-inline-images
  357 +--ii-min-bytes=size-in-bytes
  358 +
  359 +Don't externalize inline images smaller than this size. The
  360 +default is 1,024. Use 0 for no minimum.
  361 +.TP
  362 +.B --min-version \-\- set minimum PDF version
  363 +--min-version=version
  364 +
  365 +Force the PDF version of the output to be at least the specified
  366 +version. The version number format is
  367 +"major.minor[.extension-level]", which sets the version header
  368 +to "major.minor" and the extension level, if specified, to
  369 +"extension-level".
  370 +.TP
  371 +.B --force-version \-\- set output PDF version
  372 +--force-version=version
  373 +
  374 +Force the output PDF file's PDF version header to be the specified
  375 +value, even if the file uses features that may not be available
  376 +in that version.
  377 +.SH PAGE-RANGES (page range syntax)
  378 +A full description of the page range syntax, with examples, can be
  379 +found in the manual. Summary:
  380 +
  381 +.IP \[bu]
  382 +a,b,c pages a, b, and c
  383 +.IP \[bu]
  384 +a-b pages a through b inclusive; if a > b, this counts down
  385 +.IP \[bu]
  386 +r<n> where <n> represents a number is the <n>th page from the end
  387 +.IP \[bu]
  388 +z the last page, same as r1
  389 +
  390 +You can append :even or :odd to select every other page from the
  391 +resulting set of pages, where :odd starts with the first page and
  392 +:even starts with the second page. These are odd and even pages
  393 +from the resulting set, not based on the original page numbers.
  394 +.SH MODIFICATION (change parts of the PDF)
  395 +Modification options make systematic changes to certain parts of
  396 +the PDF, causing the PDF to render differently from the original.
  397 +.PP
  398 +Related Options:
  399 +.TP
  400 +.B --pages \-\- begin page selection
  401 +--pages file [--password=password] [page-range] [...] --
  402 +
  403 +Run qpdf --help=page-selection for details.
  404 +.TP
  405 +.B --collate \-\- collate with --pages
  406 +--collate[=n]
  407 +
  408 +Collate rather than concatenate pages specified with --pages.
  409 +With a numeric parameter, collate in groups of n. The default
  410 +is 1. Run qpdf --help=page-selection for additional details.
  411 +.TP
  412 +.B --split-pages \-\- write pages to separate files
  413 +--split-pages[=n]
  414 +
  415 +This option causes qpdf to create separate output files for each
  416 +page or group of pages rather than a single output file.
  417 +
  418 +File names are generated from the specified output file as follows:
  419 +
  420 +.IP \[bu]
  421 +If the string %d appears in the output file name, it is replaced with a
  422 +zero-padded page range starting from 1
  423 +.IP \[bu]
  424 +Otherwise, if the output file name ends in .pdf (case insensitive), a
  425 +zero-padded page range, preceded by a dash, is inserted before the file
  426 +extension
  427 +.IP \[bu]
  428 +Otherwise, the file name is appended with a zero-padded page range
  429 +preceded by a dash.
  430 +
  431 +Page ranges are single page numbers for single-page groups or first-last
  432 +for multi-page groups.
  433 +.TP
  434 +.B --overlay \-\- begin overlay options
  435 +--overlay file [options] --
  436 +
  437 +Overlay pages from another file on the output.
  438 +Run qpdf --help=overlay-underlay for details.
  439 +.TP
  440 +.B --underlay \-\- begin underlay options
  441 +--underlay file [options] --
  442 +
  443 +Underlay pages from another file on the output.
  444 +Run qpdf --help=overlay-underlay for details.
  445 +.TP
  446 +.B --flatten-rotation \-\- remove rotation from page dictionary
  447 +For each page that is rotated using the /Rotate key in the
  448 +page's dictionary, remove the /Rotate key and implement the
  449 +identical rotation semantics by modifying the page's contents.
  450 +This can be useful if a broken PDF viewer fails to properly
  451 +consider page rotation metadata.
  452 +.TP
  453 +.B --flatten-annotations \-\- push annotations into content
  454 +--flatten-annotations=parameter
  455 +
  456 +Push page annotations into the content streams. This may be
  457 +necessary in some case when printing or splitting files.
  458 +Parameters: "all", "print", "screen".
  459 +.TP
  460 +.B --rotate \-\- rotate pages
  461 +--rotate=[+|-]angle[:page-range]
  462 +
  463 +Rotate specified pages by multiples of 90 degrees specifying
  464 +either absolute or relative angles. "angle" may be 0, 90, 180,
  465 +or 270. You almost always want to use +angle or -angle rather
  466 +than just angle, as discussed in the manual. Run
  467 +qpdf --help=page-ranges for help with page ranges.
  468 +.TP
  469 +.B --generate-appearances \-\- generate appearances for form fields
  470 +PDF form fields consist of values and appearances, which may be
  471 +inconsistent with each other if a form field value has been
  472 +modified without updating its appearance. This option tells qpdf
  473 +to generate new appearance streams. There are some limitations,
  474 +which are discussed in the manual.
  475 +.TP
  476 +.B --optimize-images \-\- use efficient compression for images
  477 +Attempt to use DCT (JPEG) compression for images that fall
  478 +within certain constraints as long as doing so decreases the
  479 +size in bytes of the image. See also help for the following
  480 +options:
  481 + --oi-min-width
  482 + --oi-min-height
  483 + --oi-min-area
  484 + --keep-inline-images
  485 +.TP
  486 +.B --oi-min-width \-\- minimum width for --optimize-images
  487 +--oi-min-width=width
  488 +
  489 +Don't optimize images whose width is below the specified value.
  490 +.TP
  491 +.B --oi-min-height \-\- minimum height for --optimize-images
  492 +--oi-min-height=height
  493 +
  494 +Don't optimize images whose height is below the specified value.
  495 +.TP
  496 +.B --oi-min-area \-\- minimum area for --optimize-images
  497 +--oi-min-area=area-in-pixels
  498 +
  499 +Don't optimize images whose area in pixels is below the specified value.
  500 +.TP
  501 +.B --keep-inline-images \-\- exclude inline images from optimization
  502 +Prevent inline images from being considered by --optimize-images.
  503 +.TP
  504 +.B --remove-page-labels \-\- remove explicit page numbers
  505 +Exclude page labels (explicit page numbers) from the output file.
  506 +.SH ENCRYPTION (create encrypted files)
  507 +Create encrypted files. Usage:
  508 +
  509 +--encrypt \
  510 + [--user-password=user-password] \
  511 + [--owner-password=owner-password] \
  512 + --bits=key-length [options] --
  513 +
  514 +OR
  515 +
  516 +--encrypt user-password owner-password key-length [options] --
  517 +
  518 +The first form, with flags for the passwords and bit length, was
  519 +introduced in qpdf 11.7.0. Only the --bits option is is mandatory.
  520 +This form allows you to use any text as the password. If passwords
  521 +are specified, they must be given before the --bits option.
  522 +
  523 +The second form has been in qpdf since the beginning and wil
  524 +continue to be supported. Either or both of user-password and
  525 +owner-password may be empty strings.
  526 +
  527 +The key-length parameter must be either 40, 128, or 256. The user
  528 +and/or owner password may be omitted. Omitting either pasword
  529 +enables the PDF file to be opened without a password. Specifying
  530 +the same value for the user and owner password and specifying an
  531 +empty owner password are both considered insecure.
  532 +
  533 +Encryption options are terminated by "--" by itself.
  534 +
  535 +40-bit encryption is insecure, as is 128-bit encryption without
  536 +AES. Use 256-bit encryption unless you have a specific reason to
  537 +use an insecure format, such as testing or compatibility with very
  538 +old viewers. You must use the --allow-weak-crypto to create
  539 +encrypted files that use insecure cryptographic algorithms. The
  540 +--allow-weak-crypto flag appears outside of --encrypt ... --
  541 +(before --encrypt or after --).
  542 +
  543 +Available options vary by key length. Not all readers respect all
  544 +restrictions. Different PDF readers respond differently to various
  545 +combinations of options. Sometimes a PDF viewer may show you
  546 +restrictions that differ from what you selected. This is probably
  547 +not a bug in qpdf.
  548 +
  549 +Options for 40-bit only:
  550 + --annotate=[y|n] restrict comments, filling forms, and signing
  551 + --extract=[y|n] restrict text/graphic extraction
  552 + --modify=[y|n] restrict document modification
  553 + --print=[y|n] restrict printing
  554 +
  555 +Options for 128-bit or 256-bit:
  556 + --accessibility=[y|n] restrict accessibility (usually ignored)
  557 + --annotate=[y|n] restrict commenting/filling form fields
  558 + --assemble=[y|n] restrict document assembly
  559 + --extract=[y|n] restrict text/graphic extraction
  560 + --form=[y|n] restrict filling form fields
  561 + --modify-other=[y|n] restrict other modifications
  562 + --modify=modify-opt control modify access by level
  563 + --print=print-opt control printing access
  564 + --cleartext-metadata prevent encryption of metadata
  565 +
  566 +For 128-bit only:
  567 + --use-aes=[y|n] indicates whether to use AES encryption
  568 + --force-V4 forces use of V=4 encryption handler
  569 +
  570 +For 256-bit only:
  571 + --force-R5 forces use of deprecated R=5 encryption
  572 + --allow-insecure allow user password with empty owner password
  573 +
  574 +Values for print-opt:
  575 + none disallow printing
  576 + low allow only low-resolution printing
  577 + full allow full printing
  578 +
  579 +Values for modify-opt:
  580 + none allow no modifications
  581 + assembly allow document assembly only
  582 + form assembly + filling in form fields and signing
  583 + annotate form + commenting and modifying forms
  584 + all allow full document modification
  585 +.PP
  586 +Related Options:
  587 +.TP
  588 +.B --user-password \-\- specify user password
  589 +--user-password=user-password
  590 +
  591 +Set the user password of the encrypted file.
  592 +.TP
  593 +.B --owner-password \-\- specify owner password
  594 +--owner-password=owner-password
  595 +
  596 +Set the owner password of the encrypted file.
  597 +.TP
  598 +.B --bits \-\- specify encryption key length
  599 +--bits={48|128|256}
  600 +
  601 +Specify the encryption key length. For best security, always use
  602 +a key length of 256.
  603 +.TP
  604 +.B --accessibility \-\- restrict document accessibility
  605 +--accessibility=[y|n]
  606 +
  607 +This option is ignored except with very old encryption formats.
  608 +The current PDF specification does not allow restriction of
  609 +document accessibility. This option is not available with 40-bit
  610 +encryption.
  611 +.TP
  612 +.B --annotate \-\- restrict document annotation
  613 +--annotate=[y|n]
  614 +
  615 +Enable/disable modifying annotations including making comments
  616 +and filling in form fields. For 128-bit and 256-bit encryption,
  617 +this also enables editing, creating, and deleting form fields
  618 +unless --modify-other=n or --modify=none is also specified.
  619 +.TP
  620 +.B --assemble \-\- restrict document assembly
  621 +--assemble=[y|n]
  622 +
  623 +Enable/disable document assembly (rotation and reordering of
  624 +pages). This option is not available with 40-bit encryption.
  625 +.TP
  626 +.B --extract \-\- restrict text/graphic extraction
  627 +--extract=[y|n]
  628 +
  629 +Enable/disable text/graphic extraction for purposes other than
  630 +accessibility.
  631 +.TP
  632 +.B --form \-\- restrict form filling
  633 +--form=[y|n]
  634 +
  635 +Enable/disable whether filling form fields is allowed even if
  636 +modification of annotations is disabled. This option is not
  637 +available with 40-bit encryption.
  638 +.TP
  639 +.B --modify-other \-\- restrict other modifications
  640 +--modify-other=[y|n]
  641 +
  642 +Enable/disable modifications not controlled by --assemble,
  643 +--annotate, or --form. --modify-other=n is implied by any of the
  644 +other --modify options. This option is not available with 40-bit
  645 +encryption.
  646 +.TP
  647 +.B --modify \-\- restrict document modification
  648 +--modify=modify-opt
  649 +
  650 +For 40-bit files, modify-opt may only be y or n and controls all
  651 +aspects of document modification.
  652 +
  653 +For 128-bit and 256-bit encryption, modify-opt values allow
  654 +enabling and disabling levels of restriction in a manner similar
  655 +to how some PDF creation tools do it. modify-opt values map to
  656 +other combinations of options as follows:
  657 +
  658 +all: allow full modification (the default)
  659 +annotate: --modify-other=n
  660 +form: --modify-other=n --annotate=n
  661 +assembly: --modify-other=n --annotate=n --form=n
  662 +none: --modify-other=n --annotate=n --form=n --assemble=n
  663 +.TP
  664 +.B --print \-\- restrict printing
  665 +--print=print-opt
  666 +
  667 +Control what kind of printing is allowed. For 40-bit encryption,
  668 +print-opt may only be y or n and enables or disables all
  669 +printing. For 128-bit and 256-bit encryption, print-opt may have
  670 +the following values:
  671 +
  672 +none: disallow printing
  673 +low: allow low-resolution printing only
  674 +full: allow full printing (the default)
  675 +.TP
  676 +.B --cleartext-metadata \-\- don't encrypt metadata
  677 +If specified, don't encrypt document metadata even when
  678 +encrypting the rest of the document. This option is not
  679 +available with 40-bit encryption.
  680 +.TP
  681 +.B --use-aes \-\- use AES with 128-bit encryption
  682 +--use-aes=[y|n]
  683 +
  684 +Enables/disables use of the more secure AES encryption with
  685 +128-bit encryption. Specifying --use-aes=y forces the PDF
  686 +version to be at least 1.6. This option is only available with
  687 +128-bit encryption. The default is "n" for compatibility
  688 +reasons. Use 256-bit encryption instead.
  689 +.TP
  690 +.B --allow-insecure \-\- allow empty owner passwords
  691 +Allow creation of PDF files with empty owner passwords and
  692 +non-empty user passwords when using 256-bit encryption.
  693 +.TP
  694 +.B --force-V4 \-\- force V=4 in encryption dictionary
  695 +This option is for testing and is never needed in practice since
  696 +qpdf does this automatically when needed.
  697 +.TP
  698 +.B --force-R5 \-\- use unsupported R=5 encryption
  699 +Use an undocumented, unsupported, deprecated encryption
  700 +algorithm that existed only in Acrobat version IX. This option
  701 +should not be used except for compatibility testing.
  702 +.SH PAGE-SELECTION (select pages from one or more files)
  703 +Use the --pages option to select pages from multiple files. Usage:
  704 +
  705 +qpdf in.pdf --pages input-file [--password=password] [page-range] \
  706 + [...] -- out.pdf
  707 +
  708 +Between --pages and the -- that terminates pages option, repeat
  709 +the following:
  710 +
  711 +filename [--password=password] [page-range]
  712 +
  713 +Document-level information, such as outlines, tags, etc., is taken
  714 +from in.pdf and is preserved in out.pdf. You can use --empty in place
  715 +of an input file to start from an empty file and just copy pages
  716 +equally from all files. You can use "." as a shorthand for the
  717 +primary input file (if not --empty). In the above example, "."
  718 +would refer to in.pdf.
  719 +
  720 +Use --password=password to specify the password for a
  721 +password-protected input file. If the same input file is used more
  722 +than once, you only need to supply the password the first time. If
  723 +the page range is omitted, all pages are selected.
  724 +
  725 +Run qpdf --help=page-ranges for help with page ranges.
  726 +
  727 +Use --collate=n to cause pages to be collated in groups of n pages
  728 +(default 1) instead of concatenating the input.
  729 +
  730 +Examples:
  731 +
  732 +.IP \[bu]
  733 +Start with in.pdf and append all pages from a.pdf and the even
  734 +pages from b.pdf, and write the output to out.pdf. Document-level
  735 +information from in.pdf is retained. Note the use of "." to refer
  736 +to in.pdf.
  737 +
  738 + qpdf in.pdf --pages . a.pdf b.pdf:even -- out.pdf
  739 +
  740 +.IP \[bu]
  741 +Take all the pages from a.pdf, all the pages from b.pdf in
  742 +reverse, and only pages 3 and 6 from c.pdf and write the result
  743 +to out.pdf. Use password "x" to open b.pdf:
  744 +
  745 + qpdf --empty --pages a.pdf b.pdf --password=x z-1 c.pdf 3,6
  746 +
  747 +More examples are in the manual.
  748 +.SH OVERLAY-UNDERLAY (overlay/underlay pages from other files)
  749 +These options allow pages from another file to be overlaid or
  750 +underlaid on the primary output. Overlaid pages are drawn on top of
  751 +the destination page and may obscure the page. Underlaid pages are
  752 +drawn below the destination page. Usage:
  753 +
  754 +{--overlay|--underlay} file
  755 + [--password=password]
  756 + [--to=page-range]
  757 + [--from=[page-range]]
  758 + [--repeat=page-range]
  759 + --
  760 +
  761 +Note the use of "--" by itself to terminate overlay/underlay options.
  762 +
  763 +For overlay and underlay, a file and optional password are specified, along
  764 +with a series of optional page ranges. The default behavior is that each
  765 +page of the overlay or underlay file is imposed on the corresponding page
  766 +of the primary output until it runs out of pages, and any extra pages are
  767 +ignored. You can also give a page range with --repeat to cause
  768 +those pages to be repeated after the original pages are exhausted.
  769 +
  770 +Run qpdf --help=page-ranges for help with page ranges.
  771 +.PP
  772 +Related Options:
  773 +.TP
  774 +.B --to \-\- destination pages for underlay/overlay
  775 +--to=page-range
  776 +
  777 +Specify the range of pages in the primary output to apply
  778 +overlay/underlay to. See qpdf --help=page-ranges for help with
  779 +the page range syntax.
  780 +.TP
  781 +.B --from \-\- source pages for underlay/overlay
  782 +--from=[page-range]
  783 +
  784 +Specify pages from the overlay/underlay file that are applied to
  785 +the destination pages. See qpdf --help=page-ranges for help
  786 +with the page range syntax. The page range may be omitted
  787 +if --repeat is used.
  788 +.TP
  789 +.B --repeat \-\- overlay/underlay pages to repeat
  790 +--repeat=page-range
  791 +
  792 +Specify pages from the overlay/underlay that are repeated after
  793 +"from" pages have been exhausted. See qpdf --help=page-ranges
  794 +for help with the page range syntax.
  795 +.SH ATTACHMENTS (work with embedded files)
  796 +It is possible to list, add, or delete embedded files (also known
  797 +as attachments) and to copy attachments from other files. See help
  798 +on individual options for details. Run qpdf --help=add-attachment
  799 +for additional details about adding attachments. See also
  800 +--help=--list-attachments and --help=--show-attachment.
  801 +.PP
  802 +Related Options:
  803 +.TP
  804 +.B --add-attachment \-\- start add attachment options
  805 +--add-attachment file [options] --
  806 +
  807 +The --add-attachment flag and its options may be repeated to add
  808 +multiple attachments. Run qpdf --help=add-attachment for details.
  809 +.TP
  810 +.B --copy-attachments-from \-\- start copy attachment options
  811 +--copy-attachments-from file [options] --
  812 +
  813 +The --copy-attachments-from flag and its options may be repeated
  814 +to copy attachments from multiple files. Run
  815 +qpdf --help=copy-attachments for details.
  816 +.TP
  817 +.B --remove-attachment \-\- remove an embedded file
  818 +--remove-attachment=key
  819 +
  820 +Remove an embedded file using its key. Get the key with
  821 +--list-attachments.
  822 +.SH PDF-DATES (PDF date format)
  823 +When a date is required, the date should conform to the PDF date
  824 +format specification, which is "D:yyyymmddhhmmssz" where "z" is
  825 +either literally upper case "Z" for UTC or a timezone offset in
  826 +the form "-hh'mm'" or "+hh'mm'". Negative timezone offsets indicate
  827 +time before UTC. Positive offsets indicate how far after. For
  828 +example, US Eastern Standard Time (America/New_York) is "-05'00'",
  829 +and Indian Standard Time (Asia/Calcutta) is "+05'30'".
  830 +
  831 +Examples:
  832 +.IP \[bu]
  833 +D:20210207161528-05'00' February 7, 2021 at 4:15:28 p.m.
  834 +.IP \[bu]
  835 +D:20210207211528Z February 7, 2021 at 21:15:28 UTC
  836 +.SH ADD-ATTACHMENT (attach (embed) files)
  837 +The options listed below appear between --add-attachment and its
  838 +terminating "--".
  839 +.PP
  840 +Related Options:
  841 +.TP
  842 +.B --key \-\- specify attachment key
  843 +--key=key
  844 +
  845 +Specify the key to use for the attachment in the embedded files
  846 +table. It defaults to the last element (basename) of the
  847 +attached file's filename.
  848 +.TP
  849 +.B --filename \-\- set attachment's displayed filename
  850 +--filename=name
  851 +
  852 +Specify the filename to be used for the attachment. This is what
  853 +is usually displayed to the user and is the name most graphical
  854 +PDF viewers will use when saving a file. It defaults to the last
  855 +element (basename) of the attached file's filename.
  856 +.TP
  857 +.B --creationdate \-\- set attachment's creation date
  858 +--creationdate=date
  859 +
  860 +Specify the attachment's creation date in PDF format; defaults
  861 +to the current time. Run qpdf --help=pdf-dates for information
  862 +about the date format.
  863 +.TP
  864 +.B --moddate \-\- set attachment's modification date
  865 +--moddate=date
  866 +
  867 +Specify the attachment's modification date in PDF format;
  868 +defaults to the current time. Run qpdf --help=pdf-dates for
  869 +information about the date format.
  870 +.TP
  871 +.B --mimetype \-\- attachment mime type, e.g. application/pdf
  872 +--mimetype=type/subtype
  873 +
  874 +Specify the mime type for the attachment, such as text/plain,
  875 +application/pdf, image/png, etc.
  876 +.TP
  877 +.B --description \-\- set attachment's description
  878 +--description="text"
  879 +
  880 +Supply descriptive text for the attachment, displayed by some
  881 +PDF viewers.
  882 +.TP
  883 +.B --replace \-\- replace attachment with same key
  884 +Indicate that any existing attachment with the same key should
  885 +be replaced by the new attachment. Otherwise, qpdf gives an
  886 +error if an attachment with that key is already present.
  887 +.SH COPY-ATTACHMENTS (copy attachments from another file)
  888 +The options listed below appear between --copy-attachments-from and
  889 +its terminating "--".
  890 +
  891 +To copy attachments from a password-protected file, use
  892 +the --password option after the file name.
  893 +.PP
  894 +Related Options:
  895 +.TP
  896 +.B --prefix \-\- key prefix for copying attachments
  897 +--prefix=prefix
  898 +
  899 +Prepend a prefix to each key; may be needed if there are
  900 +duplicate attachment keys. This affects the key only, not the
  901 +file name.
  902 +.SH INSPECTION (inspect PDF files)
  903 +These options provide tools for inspecting PDF files. When any of
  904 +the options in this section are specified, no output file may be
  905 +given.
  906 +.PP
  907 +Related Options:
  908 +.TP
  909 +.B --is-encrypted \-\- silently test whether a file is encrypted
  910 +Silently exit with a code indicating the file's encryption status:
  911 +
  912 +0: the file is encrypted
  913 +1: not used
  914 +2: the file is not encrypted
  915 +
  916 +This can be used with password-protected files even if you don't
  917 +know the password.
  918 +.TP
  919 +.B --requires-password \-\- silently test a file's password
  920 +Silently exit with a code indicating the file's password status:
  921 +
  922 +0: a password, other than as supplied, is required
  923 +1: not used
  924 +2: the file is not encrypted
  925 +3: the file is encrypted, and correct password (if any) has been supplied
  926 +.TP
  927 +.B --check \-\- partially check whether PDF is valid
  928 +Check the structure of the PDF file as well as a number of other
  929 +aspects of the file, and write information about the file to
  930 +standard output. Note that qpdf does not perform any validation
  931 +of the actual PDF page content or semantic correctness of the
  932 +PDF file. It merely checks that the PDF file is syntactically
  933 +valid. See also qpdf --help=exit-status.
  934 +.TP
  935 +.B --show-encryption \-\- information about encrypted files
  936 +Show document encryption parameters. Also show the document's
  937 +user password if the owner password is given and the file was
  938 +encrypted using older encryption formats that allow user
  939 +password recovery.
  940 +.TP
  941 +.B --show-encryption-key \-\- show key with --show-encryption
  942 +When used with --show-encryption or --check, causes the
  943 +underlying encryption key to be displayed.
  944 +.TP
  945 +.B --check-linearization \-\- check linearization tables
  946 +Check to see whether a file is linearized and, if so, whether
  947 +the linearization hint tables are correct.
  948 +.TP
  949 +.B --show-linearization \-\- show linearization hint tables
  950 +Check and display all data in the linearization hint tables.
  951 +.TP
  952 +.B --show-xref \-\- show cross reference data
  953 +Show the contents of the cross-reference table or stream (object
  954 +locations in the file) in a human-readable form. This is
  955 +especially useful for files with cross-reference streams, which
  956 +are stored in a binary format.
  957 +.TP
  958 +.B --show-object \-\- show contents of an object
  959 +--show-object={trailer|obj[,gen]}
  960 +
  961 +Show the contents of the given object. This is especially useful
  962 +for inspecting objects that are inside of object streams (also
  963 +known as "compressed objects").
  964 +.TP
  965 +.B --raw-stream-data \-\- show raw stream data
  966 +When used with --show-object, if the object is a stream, write
  967 +the raw (compressed) binary stream data to standard output
  968 +instead of the object's contents. See also
  969 +--filtered-stream-data.
  970 +.TP
  971 +.B --filtered-stream-data \-\- show filtered stream data
  972 +When used with --show-object, if the object is a stream, write
  973 +the filtered (uncompressed, potentially binary) stream data to
  974 +standard output instead of the object's contents. See also
  975 +--raw-stream-data.
  976 +.TP
  977 +.B --show-npages \-\- show number of pages
  978 +Print the number of pages in the input file on a line by itself.
  979 +Useful for scripts.
  980 +.TP
  981 +.B --show-pages \-\- display page dictionary information
  982 +Show the object and generation number for each page dictionary
  983 +object and for each content stream associated with the page.
  984 +.TP
  985 +.B --with-images \-\- include image details with --show-pages
  986 +When used with --show-pages, also shows the object and
  987 +generation numbers for the image objects on each page.
  988 +.TP
  989 +.B --list-attachments \-\- list embedded files
  990 +Show the key and stream number for each embedded file. Combine
  991 +with --verbose for more detailed information.
  992 +.TP
  993 +.B --show-attachment \-\- export an embedded file
  994 +--show-attachment=key
  995 +
  996 +Write the contents of the specified attachment to standard
  997 +output as binary data. Get the key with --list-attachments.
  998 +.SH JSON (JSON output for PDF information)
  999 +Show information about the PDF file in JSON format. Please see the
  1000 +JSON chapter in the qpdf manual for details.
  1001 +.PP
  1002 +Related Options:
  1003 +.TP
  1004 +.B --json \-\- show file in JSON format
  1005 +--json[=version]
  1006 +
  1007 +Generate a JSON representation of the file. This is described in
  1008 +depth in the JSON section of the manual. "version" may be a
  1009 +specific version or "latest" (the default). Run qpdf --json-help
  1010 +for a description of the generated JSON object.
  1011 +.TP
  1012 +.B --json-help \-\- show format of JSON output
  1013 +--json-help[=version]
  1014 +
  1015 +Describe the format of the JSON output by writing to standard
  1016 +output a JSON object with the same keys and with values
  1017 +containing descriptive text.
  1018 +.TP
  1019 +.B --json-key \-\- limit which keys are in JSON output
  1020 +--json-key=key
  1021 +
  1022 +This option is repeatable. If given, only the specified
  1023 +top-level keys will be included in the JSON output. Otherwise,
  1024 +all keys will be included. With --json-output, when not given,
  1025 +only the "qpdf" key will appear in the output.
  1026 +.TP
  1027 +.B --json-object \-\- limit which objects are in JSON
  1028 +--json-object={trailer|obj[,gen]}
  1029 +
  1030 +This option is repeatable. If given, only specified objects will
  1031 +be shown in the "objects" key of the JSON output. Otherwise, all
  1032 +objects will be shown.
  1033 +.TP
  1034 +.B --json-stream-data \-\- how to handle streams in json output
  1035 +--json-stream-data={none|inline|file}
  1036 +
  1037 +When used with --json, this option controls whether streams in
  1038 +json output should be omitted, written inline (base64-encoded)
  1039 +or written to a file. If "file" is chosen, the file will be the
  1040 +name of the output file appended with -nnn where nnn is the
  1041 +object number. The prefix can be overridden with
  1042 +--json-stream-prefix. The default is "none", except
  1043 +when --json-output is specified, in which case the default is
  1044 +"inline".
  1045 +.TP
  1046 +.B --json-stream-prefix \-\- prefix for json stream data files
  1047 +--json-stream-prefix=file-prefix
  1048 +
  1049 +When used with --json-stream-data=file, --json-stream-data=file-prefix
  1050 +sets the prefix for stream data files, overriding the default,
  1051 +which is to use the output file name. Whatever is given here
  1052 +will be appended with -nnn to create the name of the file that
  1053 +will contain the data for the stream stream in object nnn.
  1054 +.TP
  1055 +.B --json-output \-\- apply defaults for JSON serialization
  1056 +--json-output[=version]
  1057 +
  1058 +Implies --json=version. Changes default values for certain
  1059 +options so that the JSON output written is the most faithful
  1060 +representation of the original PDF and contains no additional
  1061 +JSON keys. See also --json-stream-data, --json-stream-prefix,
  1062 +and --decode-level.
  1063 +.TP
  1064 +.B --json-input \-\- input file is qpdf JSON
  1065 +Treat the input file as a JSON file in qpdf JSON format. See the
  1066 +"qpdf JSON Format" section of the manual for information about
  1067 +how to use this option.
  1068 +.TP
  1069 +.B --update-from-json \-\- update a PDF from qpdf JSON
  1070 +--update-from-json=qpdf-json-file
  1071 +
  1072 +Update a PDF file from a JSON file. Please see the "qpdf JSON"
  1073 +chapter of the manual for information about how to use this
  1074 +option.
  1075 +.SH TESTING (options for testing or debugging)
  1076 +The options below are useful when writing automated test code that
  1077 +includes files created by qpdf or when testing qpdf itself.
  1078 +.PP
  1079 +Related Options:
  1080 +.TP
  1081 +.B --static-id \-\- use a fixed document ID
  1082 +Use a fixed value for the document ID. This is intended for
  1083 +testing only. Never use it for production files. See also
  1084 +qpdf --help=--deterministic-id.
  1085 +.TP
  1086 +.B --static-aes-iv \-\- use a fixed AES vector
  1087 +Use a static initialization vector for AES-CBC. This is intended
  1088 +for testing only so that output files can be reproducible. Never
  1089 +use it for production files. This option is not secure since it
  1090 +significantly weakens the encryption.
  1091 +.TP
  1092 +.B --linearize-pass1 \-\- save pass 1 of linearization
  1093 +--linearize-pass1=file
  1094 +
  1095 +Write the first pass of linearization to the named file. The
  1096 +resulting file is not a valid PDF file. This option is useful only
  1097 +for debugging qpdf.
  1098 +.TP
  1099 +.B --test-json-schema \-\- test generated json against schema
  1100 +This is used by qpdf's test suite to check consistency between
  1101 +the output of qpdf --json and the output of qpdf --json-help.
  1102 +.TP
  1103 +.B --report-memory-usage \-\- best effort report of memory usage
  1104 +This is used by qpdf's performance test suite to report the
  1105 +maximum amount of memory used in supported environments.
  1106 +.SH SEE ALSO
  1107 +.PP
  1108 +For a summary of qpdf's options, please run \fBqpdf \-\-help\fR.
  1109 +A complete manual can be found at https://qpdf.readthedocs.io.
... ...
manual/release-notes.rst
... ... @@ -80,6 +80,11 @@ Planned changes for future 12.x (subject to change):
80 80 ``README-maintainer.md`` for a detailed explanation of how to
81 81 maintain this.
82 82  
  83 + - Package Enhancements:
  84 +
  85 + - A UNIX man page is now automatically generated from the
  86 + documentation. It contains the same text as ``qpdf --help=all``.
  87 +
83 88 - Library Enhancements:
84 89  
85 90 - Add C++ functions ``qpdf_c_wrap`` and ``qpdf_c_get_qpdf`` to the
... ...