A3 pdf file is cropped and printed on A4 paper
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cups (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Intrepid |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Binary package hint: cups
I have several A3 sized pdf files that do not print correctly:
A3 landscape or portait format prints cropped to A4 paper. The landscape print is incorrectly rotated by 90° and then cropped to A4.
I print to a Postscript printer that understands PDF directly. If i upload the file directly to the printer via web interface (no cups in the processing) and let the printer decide on paper size, it prints correctly on A3 paper. I have tested this on 1.3.9-2ubuntu5 (Intrepid). On a server running Debian Lenny with cups 1.3.8-1lenny4, the same A3 files get scaled to A4 and printed on A4 paper, while the rotation seems correct for landscape and portrait.
Related branches
CVE References
Joachim Schwender (jschwender) wrote : | #1 |
Joachim Schwender (jschwender) wrote : | #2 |
Till Kamppeter (till-kamppeter) wrote : | #3 |
For me your attached files print correctly if
1. You have installed the latest CUPS package (1.3.9-2ubuntu6). Note that 2ubuntu5 is broken. Do not use it.
2. Either the default paper size for your print queue is set to A3 or you select A3 paper size when sending the job.
The following test command lines gave always correct results for me (display the PostScript file /tmp/printout after each "lpr" call):
cupsctl LogLevel=debug
cupsctl FileDevice=yes
lpadmin -p a -E -v /tmp/printout -P /usr/share/
lpr -P a A3landscape.pdf
lpr -P a A3portrait.pdf
lpadmin -p a -o PageSize=A4
lpr -P a -o PageSize=A3 A3landscape.pdf
lpr -P a -o PageSize=A3 A3portrait.pdf
If you print out of evince ("Document Viewer") you MUST choose the correct paper size (A3 here) under "Print Setup" before printing. Note also that evince does not remember the paper size which you have selected for your last printout. The problem is evince here, due to not very user-friendly handling of the page size.
Changed in cups: | |
importance: | Undecided → Medium |
status: | New → Confirmed |
Joachim Schwender (jschwender) wrote : | #4 |
I can confirm that if you specify explicitly A3 it prints correctly. But is this the way it should be? If i print to Lenny cups queue or Sarge, i don't have to specify anything and i have mixed format PDFs in a directory and just do a
lpr -P xerox1 *.pdf
and each document is printed correctly, no matter if A3 or A4. This does not work with 2ubuntu6 version. I strongly disagree that it is a correct and expected print processing that If i print an A3 document it comes out cropped on A4 paper?? It can be better, the information is there, cups has just to use it, it it obviously worked as expected in other/older versions.
And i am not talking about printing from GUI applications like evince or acroread, just because you have to click on thousand buttons to get what you want, which makes it error prone.
Joachim Schwender (jschwender) wrote : | #5 |
A combined printjob does also NOT print properly:
lpr -P xerox1 -o PageSize=A4 A4quer.pdf -o PageSize=A3 A3portrait.pdf -o PageSize=A4 quer7232.pdf
The last option wins. That is not the expected behavior.
Joachim Schwender (jschwender) wrote : | #6 |
A document which contains a combination of A4,A3,A4 pages prints completely on A4 paper, the A3 page cropped. This is not good.
Till Kamppeter (till-kamppeter) wrote : | #7 |
Can you rename your /usr/lib/
Now try to print. does it solve your problem?
Till Kamppeter (till-kamppeter) wrote : | #8 |
Joachim Schwender (jschwender) wrote : | #9 |
Same result.
Till Kamppeter (till-kamppeter) wrote : | #10 |
Can you do
sudo mv /usr/lib/
sudo mv /usr/lib/
sudo /etc/init.d/cups restart
Does it now print as expected?
Joachim Schwender (jschwender) wrote : | #11 |
It still prints A3 pdf on A4 paper, but it scales it down instead of cropping.
Till Kamppeter (till-kamppeter) wrote : | #12 |
Can you now try
cat > pdftopdf.dummy << EOF
#!/bin/sh
cat \$6
EOF
sudo cp pdftopdf.dummy /usr/lib/
sudo chmod 755 /usr/lib/
sudo /etc/init.d/cups restart
and try to print again? Does this work now?
Till Kamppeter (till-kamppeter) wrote : | #13 |
After you have tried out what happens after following the instructions of my previous comment, please try the following:
sudo cp/usr/
lpr -o pdftopdfAutoRot
Joachim Schwender (jschwender) wrote : | #14 |
After previous instructions it printed scaled on A4.
With the pdftopdf filter restored it prints A3 to A4 paper with scaling down. Rotations looks ok.
Till Kamppeter (till-kamppeter) wrote : | #15 |
So this means that supplying "-o pdftopdfAutoRot
Till Kamppeter (till-kamppeter) wrote : | #16 |
- pdftopdf filter with possible fix (x86_64) Edit (837.0 KiB, application/octet-stream)
I think I have found a fix for the bug in the pdftopdf CUPS filter. I attach an x86_64 binary of the fixed filter. If you need I can also make a 32-bit (i386) binary.
Do
sudo cp pdftopdf.new /usr/lib/
sudo chmod 755 /usr/lib/
and try again. Is everything working for you now?
Till Kamppeter (till-kamppeter) wrote : | #17 |
- debdiff to apply the proposed fix to Intrepid Edit (1.5 KiB, text/plain)
The source of the proposed fix, as a debdiff for the CUPS of current Intrepid, is attached.
Till Kamppeter (till-kamppeter) wrote : | #18 |
The patch is also applied to the BZR repository of CUPS at Debian, so it will also go into the next Jaunty package.
Changed in cups: | |
status: | Confirmed → Fix Committed |
Joachim Schwender (jschwender) wrote : | #19 |
The A3 files still print on A4 paper, but now cropping is lower left corner for landscape instead of center cropping like before. If i specify explicitly "-o PaperSize=A3" it chooses A3 paper and prints in correct scaling with correct rotation.
Till Kamppeter (till-kamppeter) wrote : | #20 |
What do you get with
lpr -o pdftopdfAutoRot
now?
Joachim Schwender (jschwender) wrote : | #21 |
this option does not change anything with A3landscape.pdf or A4portrait.pdf. Also changing false to true does not change anything. Result is: it prints cropped to A4 paper.
Till Kamppeter (till-kamppeter) wrote : | #22 |
- Now pdftopdf CUPS filter with an additional fix (x86_64) Edit (837.6 KiB, application/octet-stream)
I have found another bug in the pdftopdf filter which I have fixed now.Do
Download this new attachment and do again
sudo cp pdftopdf /usr/lib/
sudo chmod 755 /usr/lib/
and try again. Is everything working for you now?
Till Kamppeter (till-kamppeter) wrote : | #23 |
- New debdiff with the latest fix. Edit (2.0 KiB, text/plain)
Attached is the new debdiff to show the change in the source code.
Till Kamppeter (till-kamppeter) wrote : | #24 |
I have also committed the new fix to the Debian BZR repository of CUPS now to get it into Jaumty.
Joachim Schwender (jschwender) wrote : | #25 |
Result with this newest pdftopdf filter is that it scales A3 documents to A4 paper, landscape and portrait rotation works ok.
It still does not choose A3 paper.
Till Kamppeter (till-kamppeter) wrote : | #26 |
I am not sure whether CUPS really supports paper size selection by the document. One could try to modify the pdftops and pstopdf filters to not impose the paper size from the PPD to the document
Now I think we should at least be on the state that we have the same behavior as in Hardy. Am I right?
Till Kamppeter (till-kamppeter) wrote : | #27 |
- Patched pdftops filter. Edit (47.7 KiB, application/octet-stream)
Can you try the attached pdftops filter? I have modified it to keep the document's paper size as long as "fitplot" is NOT used.
Proceed the same way as with the pdftopdf filter.
Till Kamppeter (till-kamppeter) wrote : | #28 |
- Source code patch for pdftops filter Edit (771 bytes, text/plain)
Here is the source code patch which lead to the filter of the previous posting.
Till Kamppeter (till-kamppeter) wrote : | #29 |
- pstopdf filter which conserves document's page size. Edit (3.8 KiB, text/plain)
To be able to print also PostScript files you will have to replace also the pstopdf filter by this attachment.
Till Kamppeter (till-kamppeter) wrote : | #30 |
Note: The attachments of the last three postings are probably not perfect. They will probably make a paper size given by the PPD or the command line completely ignored, at least when printing PostScript or PDF files (what usually comes from applications). Especially if your printer has A4 as standard size and you print a PostScript or PDF in Letter format, the printer can reject it.
But please test anyway, at least to see whether they lead to the desired behavior.
Then we could find a compromise, like imposing paper sizes from the command line but not from the PPD, and anyway, if you print with the "fitplot" option, the paper sizes get imposed again.
Joachim Schwender (jschwender) wrote : | #31 |
- pdf with both A3+A4 combined Edit (22.5 KiB, application/pdf)
1. Version 1.2 supported this, we have always been using this command line printing for these print jobs, it used to work as long as we had debian sarge with a self built vanilla v1.2 on the print server. It makes sense to support paper picking.
2. pdftops filter works partly: paper is picked properly for single print jobs with only one paper format, but a print file with a combination of A4 and A3 is complately printed to A4 paper with scale down. This is at least much better than cropping. Great! Thanks!
For my need here right now that functionality would be sufficient, but wouldn't it be good if combined formats are also printed correctly?
3. mentioned restrictions: Does that mean that if i print from an application i cannot choose the paper? That would also mean if i print an A3 document on a printer that is set to A4 as standard, i don't have to pick the paper and it is printed correctly? Our printers here would anyway reject a letter sized print job unless the printer is set to make it fit on a A4 paper, which is what i have set on all printers here.
Till Kamppeter (till-kamppeter) wrote : | #32 |
Can you replace your pdftops filter by this one
http://
Then the document page size should get conserved from the beginning to the end.
Joachim Schwender (jschwender) wrote : | #33 |
single A3 pdfs are printed A3 paper, a combined A4+A3 pdf prints on A4 papaer with cropping.
Till Kamppeter (till-kamppeter) wrote : | #34 |
Independent what pdftops filter is used, the tray seems to be generally selected by the size of the first page.
This means that the PostScript data stream produced when running the Ghostscript-based pdftops filter does not trigger tray changes when the page size changes. Pages are not scaled to fit into any given format.
The Poppler-based pdftops filter scales down all pages, in your last test not to the size given by CUPS as the filter is patched to not pass on the PPD or command line paper size. It seems to scale the pages to the size of the first page.
I have also tried to run
pdftops -noshrink -nocenter -nocrop combined.pdf
Then the output consists of all pages in original size but put onto A4 sheets in the orientation of the original pages. The A3 pages are cropped then. It seems that Poppler's pdftops is not able to produce documents with different paper sizes for the different pages.
Till Kamppeter (till-kamppeter) wrote : | #35 |
The problem of the Ghostscript-based pdftops filter is caused by the following Ghostscript bug:
http://
The bug is fixed in the latest SVN state of Ghostscript which will turn Ghostscript 8.64 on February 1st.
I try to print on C5 envelopes.
original behaviour: render A4, crop to C5
with debdiff cups: render A4, scale to C5 (still incorrect)
with pdftops filter replacement: render to C5, print on A4 (printer asks for A4).
It seems my bug 318718 is a dup from this here. I will try to close that one.
Till Kamppeter (till-kamppeter) wrote : | #37 |
I have packaged Ghostscript 8.64 (development snapshot of two weeks before release) for Jaunty now. Please test either on a Jaunty box or by starting a live CD/USB stick and then load the updates to get the new Ghostscript. Or install the packages on Intrepid. THen download them by going here:
https:/
choose your system architecture in the list on the right and after that follow the links to each binary package (on the right). You will at least need libgs8, ghostscript, and ghostscript-x. Install the packages with "sudo dpkg -i --force-overwrite --force-depends --force-conflicts <package name> ...".
Does printing of multiple-page-size files like combined.pdf work now (using the Ghostscript-based pdftops filter)?
To make your system consistent again after the test (if you have installed Jaunty's Ghostscript on Intrepid with "sudo dpkg -i --force-overwrite --force-depends --force-conflicts <package name> ..."), do
sudo dpkg -r --force-depends ghostscript ghostscript-x libgs8
sudo apt-get install --reinstall cups
sudo apt-get install ghostscript ghostscript-x libgs8
Joachim Schwender (jschwender) wrote : | #38 |
combined.pdf still prints on A4 paper with cropping. The pdftopdf filter is still the binary that you proposed above, do i have to restore the original files??? pdftops is a shell script that you proposed, it looks to me like it uses ghostscript. I have installed jaunty package for amd64 on intrepid. It gave some complaints on dependancies for libsm6, libice6, libxt6 i don't know if that is relevant, but as my server is runing in a vserver environment without any X installed i guess it is irrelevant?
Till Kamppeter (till-kamppeter) wrote : | #39 |
You do not have to restore anything. You should have my proposed pdftopdf and pdftops filters and Ghostscript 8.64.
Check whether Ghostscript works correctly running
gs -h
ldd /usr/bin/gs
These commands should not show any errors.
Try also running the command lines from
http://
using combined.pdf as input file.
Joachim Schwender (jschwender) wrote : | #40 |
OK, i have your pdftopdf and pdftops filters and above commands give no errors.
I converted the file and sent it to cups, the result again is that it prints on A4 paper with cropping.
Till Kamppeter (till-kamppeter) wrote : | #41 |
Can you apply the patch shown in
http://
to your
/usr/share/
file and tell whether this makes your printer switching trays? Make sure that you are still with my newest pdftopdf filter, my newest Ghostscript-based script as pdftops filter and with Ghostscript 8.64.
Till Kamppeter (till-kamppeter) wrote : | #42 |
- Fixed opdfread.ps file Edit (137.7 KiB, text/plain)
If you have problems applying a patch, simply replace your /usr/share/
Joachim Schwender (jschwender) wrote : | #43 |
This did not change anything.
Till Kamppeter (till-kamppeter) wrote : | #44 |
Can you do the following:
gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=pswrite -dDEVICEWIDTHPO
nc -w1 <IP of your printer> 9100 < combined.ps
Are the trays changed correctly now?
PPD=/etc/
nc -w1 <IP of your printer> 9100 < combined2.ps
Are the tray correctly changed here?
Create a print queue identical to your existing one, but printing into a file:
cupsctl FileDevice=yes
lpadmin -p test -E -v /tmp/printout -P /etc/cups/ppd/<name of your print queue>.ppd
Print combined.pdf into this queue. Attach /tmp/printout to this bug report (you must "sudo chown" it to you to be able to open and copy it). Do you get automatic tray changes here?
Till Kamppeter (till-kamppeter) wrote : | #45 |
Do
sudo apt-get install netcat-traditional
if you do not have the "nc" command on your machine.
Joachim Schwender (jschwender) wrote : | #46 |
Till Kamppeter (till-kamppeter) wrote : | #47 |
ferro, that means that the PostScript which current Ghostscript and current Poppler are producing from PDF input does not trigger paper tray changes in your printer.
To investigate how PostScript has to look like so that tray changes will happen (so that one can improve filters in the future) can you please try the following:
Make some copies of the printout file which you have attached in the last posting.
Have a look at all four page headers, beginning with "%%Page" and ending with "%%EndPageSetup". Now we try two approaches to make the PostScript file switching trays:
1st approach: Remove the very first "%%PageBounding
2nd approach: Somewhere between "%%BeginPageSetup" and "%%EndPageSetup" setup add the line
<</PageSize [XXX YYY] /ImagingBBox null>> setpagedevice
replacing XXX and YYY by the two numbers in the beginning of the line which ends with "setpagesize".
3rd approach: Do both the 1st and the 2nd approach.
Edit always all four page headers as described. Send all the three approaches unfiltered (with the "nc ..." command line) to the printer. Which of these approaches make the printer switching trays.
If you can get hold on a machine with an old CUPS 1.2.x environment where the tray switching still worked, please make a copy of your print queue which prints into a file there, too (see my previous postings, "lpadmin -p test ....") and post the output PostScript file from there.
This is all to allow improvements of the filters in the future. For Intrepid we will make an SRU to at least get back to Hardy's behavior of scaling down the A3 pages to A4.
Joachim Schwender (jschwender) wrote : | #48 |
ok, i am out next week and will do that after i returned...
Martin Pitt (pitti) wrote : | #49 |
Accepted into intrepid-proposed, please test and give feedback here. Please see https:/
Changed in cups: | |
status: | New → Fix Committed |
Till Kamppeter (till-kamppeter) wrote : | #50 |
ferro, note that the fix for Intrepid in -proposed is only to get Hardy's behavior of scaling down the A3 pages back, not for automatic tray change.
Automatic tray change we will get back in Jaunty. I have reported your problem to CUPS upstream:
http://
Mike Sweet, author of CUPS, has solved it by imposing the page size to the document only if the page size is supplied on the command line. Otherwise the document's page size will be used.
I will also check the other filters and make them also behaving this way.
This means that then you should be able to print multiple-page size documents with automatic tray change with
lpr combined.pdf
and scale them to A4 with
lpr -o PageSize=A4 combined.pdf
Launchpad Janitor (janitor) wrote : | #51 |
This bug was fixed in the package cups - 1.3.9-12
---------------
cups (1.3.9-12) experimental; urgency=low
[ Till Kamppeter ]
* debian/
debian/
the pages when an automatic rotation did not actually take place and
do not apply the page size and margins from the PPD file or the coomand
line if no manipulations affecting the printout size are done (N-up,
scaling, fitplot, ...). This caused LP: #310575.
* debian/
automatically updated after each installation of this package (if they
use PPDs of this package).
[ Marc Deslauriers ]
* SECURITY UPDATE: denial of service by adding a large number of RSS
subscriptions (Closes: #506180, LP: #298241)
- debian/
being reached in scheduler/
- CVE-2008-5183
[ Martin Pitt ]
* pidfile.dpatch: Adapt to changes from MaxSubscriptions fix from
above.
-- Martin Pitt <email address hidden> Sun, 25 Jan 2009 12:05:44 +0100
Changed in cups: | |
status: | Fix Committed → Fix Released |
Till Kamppeter (till-kamppeter) wrote : | #52 |
I have also reported
http://
concerning automatic tray switching, as CUPS' pstops has also a bug.
Till Kamppeter (till-kamppeter) wrote : | #53 |
The CUPS bug was rejected as Ghostscript did not actually produce correct DSC-conforming PostScript in the PDF-to-PostScript conversion by the pdftops (either my script or the filter of CUPS 1.4 which will come with Jaunty's CUPS package).
The Ghostscript upstream developers have accepted a last-minute fix for this into Ghostscript 8.64 today (GS is already in code freeze), so Jaunty will ship the tray switching on multiple-page-size documents already working.
If you want to test, please test with Jaunty and wait for the next CUPS and GS uploads.
Till Kamppeter (till-kamppeter) wrote : | #54 |
I have now also reported a bug on Poppler, as Poppler's pdftops tool, which was used by Jaunty's pdftops CUPS filter formerly, does not support documents with pages of different sizes. It scales all pages to the size of the first page. Here is a link to the bug report:
Till Kamppeter (till-kamppeter) wrote : | #55 |
I have now made printing documents with pages of different pages finally working in Jaunty's CUPS and in CUPS 1.4. With the next CUPS release in Jaunty you can print such documents out of applications or from the command line. The sizes of the pages are conserved (which would make your printer switching trays) as long as you do not supply the option "fitplot" or "fit-to-page" (in system-
Martin Pitt (pitti) wrote : | #56 |
Can anyone please test the current update in intrepid-proposed?
Joachim Schwender (jschwender) wrote : | #57 |
I tested cups 1.3.9-2ubuntu7 from intrepid proposed.
All A3 prints are scaled down to A4 and printed to A4 paper. Rotation works ok.
Till Kamppeter (till-kamppeter) wrote : | #58 |
OK, this is our expected behavior for Intrepid. So the SRU can be passed on to -updates.
ferro, the complete fix is done in Jaunty. Here a job with multiple page sizes will really switch input trays if the printer provides the requested sizes.
ferro, thank you very much for your cooperation.
Launchpad Janitor (janitor) wrote : | #59 |
This bug was fixed in the package cups - 1.3.9-2ubuntu7
---------------
cups (1.3.9-2ubuntu7) intrepid-proposed; urgency=low
* debian/
debian/
the pages when an automatic rotation did not actually take place and
do not apply the page size and margins from the PPD file or the coomand
line if no manipulations affecting the printout size are done (N-up,
scaling, fitplot, ...). This caused LP: #310575.
-- Till Kamppeter <email address hidden> Mon, 10 Jan 2008 13:19:55 +0100
Changed in cups: | |
status: | Fix Committed → Fix Released |
This is the A3 portrait test file