Bug 149560 - In kpdf when printing pdf, the margins are interchanged. left and right are mixed up, as are top and bottom
Summary: In kpdf when printing pdf, the margins are interchanged. left and right are m...
Status: RESOLVED FIXED
Alias: None
Product: kpdf
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages All
: NOR normal
Target Milestone: ---
Assignee: Albert Astals Cid
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-09-05 11:25 UTC by dirkwallenstein
Modified: 2007-09-05 20:19 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Test document to demo this bug: use with kpdf; set margins; print with "Preview" enabled (2.79 KB, application/pdf)
2007-09-05 14:35 UTC, Kurt Pfeifle
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dirkwallenstein 2007-09-05 11:25:43 UTC
Version:            (using KDE KDE 3.5.7)
Installed from:    Gentoo Packages
Compiler:          gcc-4.1.2 
OS:                Linux

How to reproduce:
- open kpdf and its print-dialog
- In properties->margins adapt only one margin left or right, top or bottom to huge values
- Print 
- In the up-popping dialog, choose “print with specified margins“. Actually the choice doesn't matter.

This does _not_ happen for example when printing html from within konqueror, which has the same general printing dialog.
Printing pdf from kpdf within konqueror has the same effect - interchanged margins.
The preview within the margins-dialog shows the expected behaviour - the left margin is on the left hand side, etc. 

I use centimeters (huger values), but that has no impact (as expected).
Other things: cups-1.2.12(currently), HP DeskJet 840C Foomatic/hpijs, 
Actually I retreated from filing a bug-report regarding this topic some time ago (a year or so, using lfs), to look for a configuration problem more thoroughly. Well, i didn't find one.
Comment 1 Kurt Pfeifle 2007-09-05 14:32:42 UTC
changed $summary to take kdeprint out of the line of fire  :-)

Confirming this bug. I'll attach a test document which allows to better track down  the problem (it's just a few nested frames centered on an A4 page).

You can see how this bug exhibits itself also if you enble "Preview" in the kprinter main dialog (checkbox underneath the "Properties" button). 

Normally this test PDF I'll attach should be printed with zero margins (it's a full bleed page covering all available area). Set margins *really* to zero in kprinter, and the preview is as intended...

Now try to set different margins and see what the preview shows in each case (I used "gv" as the PostScript viewer, enabled in "kaddprinterwizard --kdeconfig" --> Preview). The left-right margin swapping does not only occur with 'huge' margins as the report seems to suggest; it already is present in the most minimal margin.

One additional bug, which is not explained by "left and right margins are swapped" is shown when you set all margins to zero, but use a bottom margin of, say 4 cm, and select "Print with specified margins". You'll notice that the image also shifts to the top, and the top area even is cropped from the page...


BTW, besides the fact that the "Print Aspect Ratio" dialog does not do what it intends to, its contents are also not easy to understand...
Comment 2 Kurt Pfeifle 2007-09-05 14:35:00 UTC
Created attachment 21549 [details]
Test document to demo this bug: use with kpdf; set margins; print with "Preview" enabled

This is the promised test document from my comment #2
Comment 3 Kurt Pfeifle 2007-09-05 15:00:30 UTC
"Print with specified margins" behaves like this in a few specific examples:

* if only left and right margins are set (and top/bottom both set to "0"), then
  left and right are swapped, the page image is *scaled* to fit into remaining 
  space  and the image is shifted to the bottom edge (zero margin bottom, 
  $whateverremains margin top)

* if only top and bottom margins are set (and left/right both set to "0"), then
  the image is *NOT* scaled at all, and image is shifted upward by the amount
  set by bottom margin (the top margin setting is completely ignored). Try it
  with both top and bottom margins set to 9cm, and left/right to 0cm....

* if you repeat that, and then add a left margin of, say 4cm, you see the page
  image gets scaled to fit into the available width, but it is still shifted
  upward by 9cm....
Comment 4 Albert Astals Cid 2007-09-05 20:19:24 UTC
SVN commit 708815 by aacid:

Sesame Street Class #1: Left is left, Right is right
Sesame Street Class #2: If you want to print parameters 0 and 1, use 0 and 1, not 0 and 0

This fixes some printing problems with margins

BUGS: 149560


 M  +1 -1      core/generator_pdf/generator_pdf.cpp  
 M  +1 -1      xpdf/xpdf/PSOutputDev.cc  


--- branches/KDE/3.5/kdegraphics/kpdf/core/generator_pdf/generator_pdf.cpp #708814:708815
@@ -466,7 +466,7 @@
     {
       pstitlechar = 0;
     }
-    PSOutputDev *psOut = new PSOutputDev(const_cast<char*>(tf.name().latin1()), const_cast<char*>(pstitlechar), pdfdoc->getXRef(), pdfdoc->getCatalog(), 1, pdfdoc->getNumPages(), psModePS, marginRight, marginBottom, paperWidth - marginLeft, paperHeight - marginTop, forceRasterize);
+    PSOutputDev *psOut = new PSOutputDev(const_cast<char*>(tf.name().latin1()), const_cast<char*>(pstitlechar), pdfdoc->getXRef(), pdfdoc->getCatalog(), 1, pdfdoc->getNumPages(), psModePS, marginLeft, marginBottom, paperWidth - marginRight, paperHeight - marginTop, forceRasterize);
 
     if (psOut->isOk())
     {
--- branches/KDE/3.5/kdegraphics/kpdf/xpdf/xpdf/PSOutputDev.cc #708814:708815
@@ -3140,7 +3140,7 @@
       writePSFmt("{0:.4g} {1:.4g} translate\n", tx, ty);
     }
     if (xScale != 1 || yScale != 1) {
-      writePSFmt("{0:.4f} {0:.4f} scale\n", xScale, yScale);
+      writePSFmt("{0:.4f} {1:.4f} scale\n", xScale, yScale);
     }
     if (clipLLX0 < clipURX0 && clipLLY0 < clipURY0) {
       writePSFmt("{0:.4g} {1:.4g} {2:.4g} {3:.4g} re W\n",