Bug 139740

Summary: kde fails to print in landscape format
Product: [Unmaintained] kdeprint Reporter: Hannes H <bugzilla>
Component: generalAssignee: KDEPrint Devel Mailinglist <kde-print-devel>
Status: RESOLVED UNMAINTAINED    
Severity: normal CC: jlayt
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: FreeBSD Ports   
OS: FreeBSD   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: this is an example pdf file
the above file printed as postscript, showing the error

Description Hannes H 2007-01-07 23:54:15 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    FreeBSD Ports
OS:                FreeBSD

to make a short, the problem is exactly like in this ages old report: http://bugs.kde.org/show_bug.cgi?id=45218

when printing something through kprint that is in landscape format the right third or quarter of the page is cut off. it looks like "the contents was turned to landscape before the underlying page was". 

i can reproduce this problem on freebsd6-stable with kde3.5.5, on another different freebsd6-stable with kde3.5.4 and on a kubuntu machine with whatever is the current version of kde on edgy eft.

this is definetly kde-related and not driver related, if i open the pdf files in kghostview i actually see a portrait page with turned (and cut off) content. (it looks ok in kpdf)

if i print through cups by commandline the printed pages are ok, if i print with kdeprint their cut off.


i have small example pdf files and i could make some screenshots, but i have no place to upload them right now...

thank you very much!
Comment 1 Hannes H 2007-01-07 23:58:50 UTC
Created attachment 19173 [details]
this is an example pdf file
Comment 2 Cristian Tibirna 2007-01-08 01:36:58 UTC
I can't reproduce this. You have to give me an exact way of reproducing.

What I did:
- click on the attachment link at the bottom of this report, in konqueror (this opens the default pdf previewer, which is the kpdf kpart)
- Use the "Print" command in the File menu of konqueror and choose "Preview" in the KDEPrint dialog that appears. The preview is OK (landscape). I stress that the preview is done with the kghostview part. I also check the properties of the printer and Landscape is selected all right, and there is no means to change this
- I print and the page comes out perfectly, in landscape.

So, please, give me the printer model, the application that you use to print (please try to use both kde applications kpdf and kghostview) and all other details that you might find interesting.

Thanks
Comment 3 Hannes H 2007-01-08 10:07:35 UTC
Created attachment 19183 [details]
the above file printed as postscript, showing the error

ok the problem is only kghostview-related, if i print with kpdf the preview is
wrong but the printed files are correct.
the problem with kghostview remains. if i print to postscript from kpdf
ghostscript is used in the background, right? because if i print to postscript
the output files show the error.
i also noticed that the error is a little different on kubuntu and on freebsd.
i have attached two postscript files in a tarball, that show the two files
produced by print-to-ps. these look exactly like the preview and like the
actual print-outs, if printed from kghostview. note that the properties show
"landscape" selected (and greyed out) on both machines.

thanks!
Comment 4 Kurt Pfeifle 2007-01-09 18:10:07 UTC
Hannes,

since you say that "the error is a little different on kubuntu and on freebsd" what is are the exact Ghostscript versions installed on each?

I've not yet closely looked at the files (only read this threat), but will do so later tonight.

From the description it looks like a typical problem with a wrongly set MediaBox or CropBox or BoundingBox statement in the PDF code respective metadata. Was the PDF created by an Adobe program by any chance, Illustrator maybe? (Though Adobe did define the standard, not all of their products work as advocated). Wrong *Box definitions can confuse Ghostscript (and therefore kghostview too) when displaying the file, or even when printing it.

Another possibility is a bug in Ghostscript itself. I seem to remember that there where versions out there that had problems with processing the *Box even if they were fully correct and compliant to the standard. 

Comment 5 Kurt Pfeifle 2007-01-10 01:22:18 UTC
Hannes,

various of your assumptions are wrong:

 (a) you do not set an orientation to a PDF when printing. Whatever it looks
     like on screen (as long as it looks good), never set an orientation. It
     will care for itself (or, the printing system will do).

 (b) if you print to file from kpdf, first of all kpdf's internal PostScript
     converter (which is pdftops, based on Xpdf) will create a PostScript. No
     Ghostscript involved here. (Ghostscript is never involved when an
     application creates its [PostScript] print data.

Can you print again to files on Kubuntu and leave orientation at the default "portrait" setting?
Comment 6 Hannes H 2007-01-10 01:41:26 UTC
(a) i didn't change or set the orientation, i just looked to what it was set automatically. what i wanted to say was that it already was set to landscape and that the orientation *couldn't* be set by hand.

(b) ok. than the issues is still with kghostview, because kpdf prints fine... or am i mistaken?

(havent checked the versions yet, sorry)
Comment 7 Kurt Pfeifle 2007-01-10 01:57:02 UTC
Ah, if the orientation *couldn't* be set manually, that's OK. Because you shouldn't with PDFs. That must be an improvement in kpdf more recently that I wasn't aware of. They probably now do disable that control in the kprinter dialog. (And if they set it to "landscape" that *must* be for fake; to just signal to the user "Yes, we know, if you look at it it looks like a landscape page").

However, if FreeBSD and Kubuntu behaved differently (as can be seen from your Bug report), then probably you have different versions of KDE or at least kpdf on those systems.

Can you check, and tell which versions?
Can you also check if the Kubuntunistas have patched their kpdf somehow?
Comment 8 Cristian Tibirna 2007-01-10 21:02:30 UTC
As per comment #3, this bug report (or better a new one, with concise explanation) should be moved to kghostview (which , btw, is in its way out for the next versions of KDE).

Hannes, please confirm (and eventually move your bug accordingly).

Thanks.
Comment 9 Kurt Pfeifle 2007-01-10 21:39:06 UTC
Final comment. I had another look at the files Hannes attached. 


kurt@soprano:~> pdfinfo bug-139740.pdf

  Title:          PerTable.ai
  Creator:        Adobe Illustrator 10.0
  Producer:       Adobe PDF library 5.00
  CreationDate:   Mon 03 Mar 2003 04:46:10 PM CET
  ModDate:        Wed 03 Sep 2003 04:05:41 PM CEST
  Tagged:         no 
  Pages:          1
  Encrypted:      no
  Page size:      792 x 612 pts (letter)
  File size:      299388 bytes
  Optimized:      yes
  PDF version:    1.4

kurt@soprano:~> head -n7 print_freebsd.ps

  %!PS-Adobe-3.0
  %%Creator: xpdf/pdftops 3.00
  %%LanguageLevel: 2
  %%DocumentSuppliedResources: (atend)
  %%DocumentMedia: plain 595 842 0 () ()
  %%BoundingBox: 0 0 595 842
  %%Pages: 1

kurt@soprano:~> head -n7 print_kubuntu.ps

  %!PS-Adobe-3.0
  %%Creator: xpdf/pdftops 3.00
  %%LanguageLevel: 2
  %%DocumentSuppliedResources: (atend)
  %%DocumentMedia: plain 793 612 0 () ()
  %%BoundingBox: 0 0 793 612
  %%Pages: 1

To sum it up: You can already see, that these two files were created by the same version of Xpdf/pdftops, but they have defined  differently their "DocumentMedia" and "BoundingBox" statements. FreeBSD is for A4, while Kubuntu is for Letter. Look more closely: FreeBSD is in "portrait" mode (higher than wide), Kubuntu is in landscape (wider than high). Let's look if there are more differences:

kurt@soprano:~> sdiff -sbB print_freebsd.ps print_kubuntu.ps

  %%DocumentMedia: plain 595 842 0 () ()  | %%DocumentMedia: plain 793 612 0 () ()
  %%BoundingBox: 0 0 595 842              | %%BoundingBox: 0 0 793 612
  595 842 false pdfSetup                  | 793 612 true pdfSetup
  36.1427 0 translate                     | 36.1427 7.16094e-15 translate

Yes! The difference between "true" and "false" for the pdfSetup is not as important as it seems. But the order of the page size parameters is! It makes Kubuntu change from portrait media orientation to landscape.

----> change the order of the pdfSetup parameters to "793 612" and gs will 
      display it alright (the "true" vs. "false" statement doesn't influence 
      this; a "clean" file will have all the other statements correct as 
      well).

One more thing: 
---------------
I used plain "gs" to look at the files. Later, I also used "gv" and "kghostview". "gv" displays even the faulty Kubuntu file correctly!! kghostview behaves like gs.

Moral:
------
  --> Find out about faulty PS files (rotation, BoundingBoxes): use "gs".
  --> Look at full file nevertheless (and change media size etc.): use "gv".
Comment 10 Kurt Pfeifle 2007-01-10 21:42:54 UTC
Above comment about "change the order..." has a typo. Those who are really interested will experiment on their own, and find out about it anyway... :-)
Comment 11 John Layt 2011-05-27 18:24:47 UTC
KDEPrint is obsolete, unmaintained and will never be revived.  Closing all open bugs.