Saturday, November 11, 2006

KPDF printing and margins

Up to now, KPDF did not let you specify the margins for printing, it always printed with 0 margins, today, seeing that from time to time there's a bug report with people asking about printing PDF with margins i started implementing it, i'm almost done, but have some problems understanding what a user wants when specifying margins.

Let's put a simple example. You have a single page A4 document that has a black rectangle drawn at 2cm of distance from each side. Now you choose to print it with 5cm margin on top. Which result should you get?

a) The printed sheet has the rectangle with these distances: bottom 1.66 cm, top 6.66 cm, left 2cm, right 2cm. That means the available height got reduced from 29,7cm to 24,7cm so distance of 2cm is now 1.66 in the vertical direction, but as available width did not change, you get aspect ratio lost.

b) The printed sheet has the rectangle with these distances: bottom 1.66 cm, top 6.66 cm, left 3.43cm, right 3.43cm. That means the available height got reduced from 29,7cm to 24,7cm so distance of 2cm is now 1.66 in the vertical direction, and to preserve aspect ratio, the available width got reduced from 21 to 17.465 cm, resulting in 1.66 + (21 - 17.465)/2 margin in left and right.

c) Something else

I don't really know what a user would expect when printing, as losing aspect ratio is always a bad idea, but case b) is quite confusing too as you get margins on the horizontal side when you only put it on the vertical side, ideas?

10 comments:

Anonymous said...

what about a checkbox called "keep aspect ratio" which lets the user decide what he wants?

Anonymous said...

Hi Albert and thanks a lot for taking care of that bug :)

As i stated in the report, the problem was when printing papers with very small margins, some text on the edge would not be printed. I also like to add margin notes, but sometimes the margins are too small for that.

Personally I have no use for very specific margins, I just need bigger margins and correct aspect ratio, so -> solution b.

Also, the UI should not be deceiving as is the case right now... If you're going to ajust the left/right/bottom margins automatically as in your example, please show it to the user so that he knows what's going on!

Thanks

Anonymous said...

Thanks for getting to this bug!

The expected behavior for me would be to keep the same aspect ratio as in solution b. KGhostView seems to get it right as far as I can tell, so maybe you could see what that does?

Thanks again!

Daniel D. said...

I would second mcenroe's comment - make it a check box thing, but more in the tune of how Adobe Reader does it on Windows:

They have a "Scale and center to fit printer margins" check box in the printing dialog.

You can make that a box, activated by the "Scale to fit:" with the following options:
x Printer Margins
o Custom margins
[00] Upper
[00] Left [00] Right
[00] Lower


I cannot imagine a situations when I would want to loose the aspect ratio. You might as well go for "scale" all the time.

Anonymous said...

acroread has a very useful page preview in the printing dialog. I'd really love to see something like that in KPDF's (or KDE's) print dialog. Then you could implement both options, and the user could choose the one she wants. As a side effect, you won't get bug reports stating that your margin implementation behaves unexpectedly.

Anonymous said...

When someone requests a margin that is will encroach on the printed page, I think the logical thing to do is crop the page accordingly.

So if they ask for a 5cm top margin crop 5cm down from the top edge of the paper. This will change the pages aspect ratio and it will print funny-looking but thats what they asked for.

I assume a revert is always available of course?!

Albert Astals Cid said...

@pipitas: Well, that is very interesting, but should be applied on kdeprint level, not on KPDF level and i really don't have time nor knowledge to do that :-/

Fela Winkelmolen said...

I would say b, negative values would be nice too (in case the .pdf has a very wide border for example)

Daniel D. said...

Just found a great centering / scaling box in Gwenview's print dialog... Stealing ready code will probably be easier.

Unknown said...

I get this message when printing business cards. What I want to happen is that the page prints in the exact size and position specified in the file, and anything that falls in the margin (which is a red stripe that extends beyond the cards) doesn't print.

What the two choices mean to me are:
Print with specified margins: the width is scaled to fit between the left and right margins, and the height is scaled to fit between the top and bottom margins, independently.
Print adapting margins to keep aspect ratio: the graphic area of the page is shrunk conformally to fit between the margins. Where it's put vertically (apparently it's infringing on the left and right margins) is not clear.
Neither is what I want.