]> git.ipfire.org Git - thirdparty/cups-filters.git/commit
libcupsfilters: Fixed pdftopdf() for asymmetric margins
authorTill Kamppeter <till.kamppeter@gmail.com>
Sun, 2 Jan 2022 03:49:32 +0000 (00:49 -0300)
committerTill Kamppeter <till.kamppeter@gmail.com>
Sun, 2 Jan 2022 04:14:35 +0000 (01:14 -0300)
commit31dfcae961ca737b7166cd6a3e7d4a30cd19f9e8
tree75a63df2d6c07f3c3273da630db204d942d44b98
parentdf55aa60412361cf254f6af02086d1d8d8b6d250
libcupsfilters: Fixed pdftopdf() for asymmetric margins

On some printers the left unprintable margin does not equal the right
one and/or the top margin does not equal the bottom one. pdftopdf()
did not always place the input pages correctly on the output sheets,
having de-centered printouts in crop-to-fit mode
("print-scaling=none") or missing content at the borders in
scale-to-fit mode ("print-scaling=fit").

Probably pdftopdf() did not get (well) tested with such printers.

This commit addresses these issues:

- In crop-to-fit mode we set the margins of the output page to
  all-zero befor starting all the math. This way we assure pages get
  centered and the correct (asymmetric) crop is done by the following
  filters (driver) or the printer (by simply ignoring the pixels
  falling into the margins). Alao for N-up here the input pages are
  filling exactly the halves, quarters, ... of the sheet, allowing
  easy mounting of booklets. pdftopdf() is producing an output PDF
  with pages of the size of the output sheet (not of its printable
  area) anyway and it does not need to passon pages where the
  unprintable margins are actually white.

- Set the auto-fit bit for crop-to-fill mode ("print-scaling=fill"),
  to assure that the pages cropped to the aspect ratio of the
  printable area of the output page are correctly scaled into that
  area (this got probably accidentally dropped in an earlier commit).

- Corrected the margin offsets at the coordinate origin for N-up
  printing in Landscape orientation (2-up, 6-up, 8-up, ...), so that
  they work with asymmetric margins.

- Let the crop() method for a PDF page not create a page smaller than
  the destination page. When "cropping" a smaller input page, set its
  crop box so that it gets centered on the output page. This makes the
  input pages always printed in original size in crop mode, even if
  they are smaller than the output page.
cupsfilters/pdftopdf/pdftopdf_processor.cc
cupsfilters/pdftopdf/qpdf_pdftopdf_processor.cc