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.