Commit ee437705fc87073d0223a005c6c5afd3fa464a7f

Authored by Jay Berkenbilt
1 parent ab9f4cc2

Update documentation for new features

manual/qpdf-manual.xml
... ... @@ -548,6 +548,16 @@ make
548 548 </listitem>
549 549 </varlistentry>
550 550 <varlistentry>
  551 + <term><option>--collate</option></term>
  552 + <listitem>
  553 + <para>
  554 + When specified, collate rather than concatenate pages from
  555 + files specified with <option>--pages</option>. See <xref
  556 + linkend="ref.page-selection"/> for additional details.
  557 + </para>
  558 + </listitem>
  559 + </varlistentry>
  560 + <varlistentry>
551 561 <term><option>--split-pages=[n]</option></term>
552 562 <listitem>
553 563 <para>
... ... @@ -966,6 +976,37 @@ make
966 976 </itemizedlist>
967 977 </para>
968 978 <para>
  979 + Starting in qpdf version 8.3, you can specify the
  980 + <option>--collate</option> option. Note that this option is
  981 + specified outside of <option>--pages&nbsp;...&nbsp;--</option>.
  982 + When <option>--collate</option> is specified, it changes the
  983 + meaning of <option>--pages</option> so that the specified files,
  984 + as modified by page ranges, are collated rather than concatenated.
  985 + For example, if you add the files <filename>odd.pdf</filename> and
  986 + <filename>even.pdf</filename> containing odd and even pages of a
  987 + document respectively, you could run <command>qpdf --collate
  988 + odd.pdf --pages odd.pdf even.pdf -- all.pdf</command> to collate
  989 + the pages. This would pick page 1 from odd, page 1 from even, page
  990 + 2 from odd, page 2 from even, etc. until all pages have been
  991 + included. Any number of files and page ranges can be specified. If
  992 + any file has fewer pages, that file is just skipped when its pages
  993 + have all been included. For example, if you ran <command>qpdf
  994 + --collate --empty --pages a.pdf 1-5 b.pdf 6-4 c.pdf r1 --
  995 + out.pdf</command>, you would get the following pages in this
  996 + order:
  997 + <itemizedlist>
  998 + <listitem><para>a.pdf page 1</para></listitem>
  999 + <listitem><para>b.pdf page 6</para></listitem>
  1000 + <listitem><para>c.pdf last page</para></listitem>
  1001 + <listitem><para>a.pdf page 2</para></listitem>
  1002 + <listitem><para>b.pdf page 5</para></listitem>
  1003 + <listitem><para>a.pdf page 3</para></listitem>
  1004 + <listitem><para>b.pdf page 4</para></listitem>
  1005 + <listitem><para>a.pdf page 4</para></listitem>
  1006 + <listitem><para>a.pdf page 5</para></listitem>
  1007 + </itemizedlist>
  1008 + </para>
  1009 + <para>
969 1010 Starting in qpdf version 8.3, when you split and merge files, any
970 1011 page labels (page numbers) are preserved in the final file. It is
971 1012 expected that more document features will be preserved by
... ... @@ -1302,6 +1343,166 @@ outfile.pdf&lt;/option&gt;
1302 1343 </listitem>
1303 1344 </varlistentry>
1304 1345 <varlistentry>
  1346 + <term><option>--flatten-annotations=<replaceable>option</replaceable></option></term>
  1347 + <listitem>
  1348 + <para>
  1349 + This option collapses annotations into the pages' contents
  1350 + with special handling for form fields. Ordinarily, an
  1351 + annotation is rendered separately and on top of the page.
  1352 + Combining annotations into the page's contents effectively
  1353 + freezes the placement of the annotations, making them look
  1354 + right after various page transformations. The library
  1355 + functionality backing this option was added for the benefit of
  1356 + programs that want to create <emphasis>n-up</emphasis> page
  1357 + layouts and other similar things that don't work well with
  1358 + annotations. The <replaceable>option</replaceable> parameter
  1359 + may be any of the following:
  1360 + <itemizedlist>
  1361 + <listitem>
  1362 + <para>
  1363 + <option>all</option>: include all annotations that are not
  1364 + marked invisible or hidden
  1365 + </para>
  1366 + </listitem>
  1367 + <listitem>
  1368 + <para>
  1369 + <option>print</option>: only include annotations that
  1370 + indicate that they should appear when the page is printed
  1371 + </para>
  1372 + </listitem>
  1373 + <listitem>
  1374 + <para>
  1375 + <option>screen</option>: omit annotations that indicate
  1376 + they should not appear on the screen
  1377 + </para>
  1378 + </listitem>
  1379 + </itemizedlist>
  1380 + </para>
  1381 + <para>
  1382 + Note that form fields are special because the annotations that
  1383 + are used to render filled-in form fields may become out of
  1384 + date from the fields' values if the form is filled in by a
  1385 + program that doesn't know how to update the appearances. If
  1386 + qpdf detects this case, its default behavior is not to flatten
  1387 + those annotations because doing so would cause the value of
  1388 + the form field to be lost. This gives you a chance to go back
  1389 + and resave the form with a program that knows how to generate
  1390 + appearances. QPDF itself can generate appearances with some
  1391 + limitations. See the <option>--generate-appearances</option>
  1392 + option below.
  1393 + </para>
  1394 + </listitem>
  1395 + </varlistentry>
  1396 + <varlistentry>
  1397 + <term><option>--generate-appearances</option></term>
  1398 + <listitem>
  1399 + <para>
  1400 + If a file contains interactive form fields and indicates that
  1401 + the appearances are out of date with the values of the form,
  1402 + this flag will regenerate appearances, subject to a few
  1403 + limitations. Note that there is not usually a reason to do
  1404 + this, but it can be necessary before using the
  1405 + <option>--flatten-annotations</option> option. Most of these
  1406 + are not a problem with well-behaved PDF files. The limitations
  1407 + are as follows:
  1408 + <itemizedlist>
  1409 + <listitem>
  1410 + <para>
  1411 + Radio button and checkbox appearances use the pre-set
  1412 + values in the PDF file. QPDF just makes sure that the
  1413 + correct appearance is displayed based on the value of the
  1414 + field. This is fine for PDF files that create their forms
  1415 + properly. Some PDF writers save appearances for fields when
  1416 + they change, which could cause some controls to have
  1417 + inconsistent appearances.
  1418 + </para>
  1419 + </listitem>
  1420 + </itemizedlist>
  1421 + <itemizedlist>
  1422 + <listitem>
  1423 + <para>
  1424 + For text fields and list boxes, any characters that fall
  1425 + outside of US-ASCII will be replaced by the
  1426 + <literal>?</literal> character.
  1427 + </para>
  1428 + </listitem>
  1429 + </itemizedlist>
  1430 + <itemizedlist>
  1431 + <listitem>
  1432 + <para>
  1433 + Quadding is ignored. Quadding is used to specify whether
  1434 + the contents of a field should be left, center, or right
  1435 + aligned with the field.
  1436 + </para>
  1437 + </listitem>
  1438 + </itemizedlist>
  1439 + <itemizedlist>
  1440 + <listitem>
  1441 + <para>
  1442 + Rich text, multi-line, and other more elaborate formatting
  1443 + directives are ignored.
  1444 + </para>
  1445 + </listitem>
  1446 + </itemizedlist>
  1447 + <itemizedlist>
  1448 + <listitem>
  1449 + <para>
  1450 + There is no support for multi-select fields or signature
  1451 + fields.
  1452 + </para>
  1453 + </listitem>
  1454 + </itemizedlist>
  1455 + If qpdf doesn't do a good enough job with your form, use an
  1456 + external application to save your filled-in form before
  1457 + processing it with qpdf.
  1458 + </para>
  1459 + </listitem>
  1460 + </varlistentry>
  1461 + <varlistentry>
  1462 + <term><option>--optimize-images</option></term>
  1463 + <listitem>
  1464 + <para>
  1465 + This flag causes qpdf to recompress all images that are not
  1466 + compressed with DCT (JPEG) using DCT compression as long as
  1467 + doing so decreases the size in bytes of the image data and the
  1468 + image does not fall below minimum specified dimensions. See
  1469 + also the <option>--oi-min-width</option>,
  1470 + <option>--oi-min-height</option>, and
  1471 + <option>--oi-min-area</option> options.
  1472 + </para>
  1473 + </listitem>
  1474 + </varlistentry>
  1475 + <varlistentry>
  1476 + <term><option>--oi-min-width=<replaceable>width</replaceable></option></term>
  1477 + <listitem>
  1478 + <para>
  1479 + Avoid optimizing images whose width is below the specified
  1480 + amount. If omitted, the default is 128 pixels. Use 0 for no
  1481 + minimum.
  1482 + </para>
  1483 + </listitem>
  1484 + </varlistentry>
  1485 + <varlistentry>
  1486 + <term><option>--oi-min-height=<replaceable>height</replaceable></option></term>
  1487 + <listitem>
  1488 + <para>
  1489 + Avoid optimizing images whose height is below the specified
  1490 + amount. If omitted, the default is 128 pixels. Use 0 for no
  1491 + minimum.
  1492 + </para>
  1493 + </listitem>
  1494 + </varlistentry>
  1495 + <varlistentry>
  1496 + <term><option>--oi-min-area=<replaceable>area-in-pixels</replaceable></option></term>
  1497 + <listitem>
  1498 + <para>
  1499 + Avoid optimizing images whose pixel count
  1500 + (width&nbsp;×&nbsp;height) is below the specified amount. If
  1501 + omitted, the default is 16,384 pixels. Use 0 for no minimum.
  1502 + </para>
  1503 + </listitem>
  1504 + </varlistentry>
  1505 + <varlistentry>
1305 1506 <term><option>--qdf</option></term>
1306 1507 <listitem>
1307 1508 <para>
... ...
qpdf/qpdf.cc
... ... @@ -130,9 +130,9 @@ struct Options
130 130 json(false),
131 131 check(false),
132 132 optimize_images(false),
133   - oi_min_width(128),
134   - oi_min_height(128),
135   - oi_min_area(16384),
  133 + oi_min_width(128), // Default values for these
  134 + oi_min_height(128), // oi flags are in --help
  135 + oi_min_area(16384), // and in the manual.
136 136 require_outfile(true),
137 137 infilename(0),
138 138 outfilename(0)
... ... @@ -1162,9 +1162,12 @@ ArgParser::argHelp()
1162 1162 << " fields; may also want --generate-appearances\n"
1163 1163 << "--generate-appearances generate appearance streams for form fields\n"
1164 1164 << "--optimize-images compress images with DCT (JPEG) when advantageous\n"
1165   - << "--oi-min-width=w do not optimize images whose width is below w\n"
  1165 + << "--oi-min-width=w do not optimize images whose width is below w;\n"
  1166 + << " default is 128. Use 0 to mean no minimum\n"
1166 1167 << "--oi-min-height=h do not optimize images whose height is below h\n"
  1168 + << " default is 128. Use 0 to mean no minimum\n"
1167 1169 << "--oi-min-area=a do not optimize images whose pixel count is below a\n"
  1170 + << " default is 16,384. Use 0 to mean no minimum\n"
1168 1171 << "--qdf turns on \"QDF mode\" (below)\n"
1169 1172 << "--linearize-pass1=file write intermediate pass of linearized file\n"
1170 1173 << " for debugging\n"
... ... @@ -3609,6 +3612,7 @@ static void handle_transformations(QPDF&amp; pdf, Options&amp; o)
3609 3612 QPDFPageDocumentHelper dh(pdf);
3610 3613 if (o.optimize_images)
3611 3614 {
  3615 + dh.pushInheritedAttributesToPage();
3612 3616 int pageno = 0;
3613 3617 std::vector<QPDFPageObjectHelper> pages = dh.getAllPages();
3614 3618 for (std::vector<QPDFPageObjectHelper>::iterator iter = pages.begin();
... ...