Bug 332331 - PDF margins are incorrect when printing because of fit-to-page option
Summary: PDF margins are incorrect when printing because of fit-to-page option
Status: RESOLVED WORKSFORME
Alias: None
Product: okular
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-19 19:40 UTC by pres1234
Modified: 2014-03-21 22:26 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pres1234 2014-03-19 19:40:21 UTC
When attempting to print a PDF file with Okular (happens with other KDE/Qt applications as well, but Okular is one I use and I don't see a better place to report it) to my HP Deskjet D2530 printer (residing on my server with the hpijs driver), the PDF is scaled down. The PDF I'm testing with has one inch margins on all sides, but when printing, additional space is added to the margins. Setting all margins to 0 within the printer properties does not fix the issue.

The page prints perfectly using lp:
$ lp /Path/to/PDF.pdf

Should also note it prints perfectly with non-KDE applications such as epdfview.

I turned on debug mode in CUPS to find what options KDE sends to CUPS. I narrowed it down to the "fit-to-page" option causing the issue.

I can reproduce the incorrect margins exactly with this command:
$ lp -o fit-to-page -o PageSize=Letter /Path/to/PDF.pdf

I see no option to disable "fit-to-page" within the printer dialog.


Reproducible: Always

Steps to Reproduce:
1. Open PDF file
2. Print PDF file
3. Observe margins on printed page do not match those on the PDF file
Actual Results:  
Margins are too large

Expected Results:  
Margins are exactly the same as the PDF file
Comment 1 Albert Astals Cid 2014-03-19 21:07:05 UTC
Your printer has hardware margins (i.e. zones it can't print), since we can't know if your pdf has margins that overlap or not with those hardware margins, we only print inside the hardware margins, otherwise if you had a pdf with no margins at all you would be missing part of the text.

Obviously this is fixable either adding an option or by doing magic trickery to see if margins overlap or not, but for now i think it's better you get all your stuff printer over none.

Also setting the print margins to 0 should basically disable that, are you sure it doesn't?
Comment 2 pres1234 2014-03-20 03:17:28 UTC
Oddly enough, setting the printer margins to 0 seems to fix it. I could have sworn it had no effect when I tried it earlier. The issue now is the margins are not saved, so I have to adjust it everytime I need to print something. 

I also see no options within CUPS or hplip to override this (or set the hardware margins to 0). The option "fit to page" exists in hplip, but it's already disabled by default.
Comment 3 Richard Llom 2014-03-20 10:05:54 UTC
(In reply to comment #2)
> Oddly enough, setting the printer margins to 0 seems to fix it. I could have
> sworn it had no effect when I tried it earlier. The issue now is the margins
> are not saved, so I have to adjust it everytime I need to print something. 
> 
Sadly, this a well known bug:
bug 198172 - printer margin settings are forgotten at restart

> I also see no options within CUPS or hplip to override this (or set the
> hardware margins to 0). The option "fit to page" exists in hplip, but it's
> already disabled by default.
> 
I think if you edit the ppd file by hand it should be possible:
/etc/cups/ppd/yourpostscriptprinter.ppd

but I never tried this.
Comment 4 pres1234 2014-03-21 04:06:14 UTC
> I think if you edit the ppd file by hand it should be possible:
> /etc/cups/ppd/yourpostscriptprinter.ppd
> 
> but I never tried this.

Thanks for pointing that out. I set the hardware margins to "0 0 612 792" within my ppd file. Before printing, this appeared as if it would work. Under the printer "Properties" in the print dialog, all of the margins had been set to 0 (automatically) and the bounding box in the small preview next to it exactly matched the page size, but when printing, the margins were still off as before. Setting the margins to 0 explictly within the print dialog (with a normal ppd) still results in the correct size being printing, so I'm not sure what's different between the two.

I'm done fooling around with this for now (wasted too much ink/paper). The best option would be to have a way to disable the "fit-to-page" option sent to CUPS. Since that doesn't seem possible currently, I'll just print using lp from the command line.

Also moved this under kdelibs/print-dialog, since it's a better fit there. This isn't an issue specific to Okular.
Comment 5 Albert Astals Cid 2014-03-21 22:26:53 UTC
It's actually specific to Okular since we're handing the lp calls on our own. But anyway, i don't see what this bug is about, you complained about 0 0 0 0 not printing correct margins but it does.

If you want to request some other features (like a way to disable fit-to-page that is not entering 0 0 0 0) please open a new bug since the subject of this one is actually not correct anymore (feel free to reference this bug number in your future bug)