Bug 18711 - When Poppler generates PostScript from PDF files the output is shifted on some PostScript printers
Summary: When Poppler generates PostScript from PDF files the output is shifted on som...
Status: RESOLVED MOVED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: All All
: medium major
Assignee: poppler-bugs
QA Contact:
URL: https://bugs.edge.launchpad.net/ubunt...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-26 04:40 UTC by Till Kamppeter
Modified: 2018-10-23 10:23 UTC (History)
6 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Sample PDF file (39.50 KB, application/pdf)
2008-11-27 02:32 UTC, Till Kamppeter
Details
PostScript file resulting from conversion with pdftops (57.68 KB, application/postscript)
2008-11-27 02:33 UTC, Till Kamppeter
Details
PostScript file resulting from printing to file out of evince (56.67 KB, application/postscript)
2008-11-27 02:34 UTC, Till Kamppeter
Details
PPD file of one of the Brother printer for which the problem occurs (20.05 KB, text/plain)
2008-11-27 02:58 UTC, Till Kamppeter
Details
PostScript file which was NOT created by converting a PDF with Poppler (149.20 KB, application/postscript)
2008-11-27 03:58 UTC, Till Kamppeter
Details
PostScript file resulting from conversion with pdftops from the XPDF package (57.75 KB, application/postscript)
2008-11-28 02:57 UTC, Till Kamppeter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Till Kamppeter 2008-11-26 04:40:07 UTC
See

https://bugs.launchpad.net/ubuntu/+source/foomatic-db/+bug/293832/

especially comments

https://bugs.launchpad.net/ubuntu/+source/foomatic-db/+bug/293832/comments/24
https://bugs.launchpad.net/ubuntu/+source/foomatic-db/+bug/293832/comments/25

The users who complain about this problem have PostScript printers maninly from Brother (on my HP printers the problem does not occur). Whenever PDF gets converted to PostScript in the printing filter chain, for example when printing from the Poppler-based Evince or when sending a PDF file directly to CUPS ("lpr <PDF file>") which triggers the Poppler-based pdftops filter, on Brother's PostScript printers (perhaps also other brands) the content of the page is moved 2-3 cm to the top, being cut at the top and leaving space on the page at the bottom.
Comment 1 Adrian Johnson 2008-11-26 05:45:13 UTC
Is the problem with printing from evince to a PS file or pdftops? The first uses the cairo output device to generate the PS output. The seconds generates uses the PS Output device.

It would help if you could provide a sample PDF, the incorrect PS output, and the steps to reproduce the problem using only poppler or evince/poppler.
Comment 2 Till Kamppeter 2008-11-26 07:28:07 UTC
Everything was done on Ubuntu Hardy and Ubuntu Intrepid.

The problem occurs with both evince and pdftops.

Tests were done with the attached PostScript file converted to PDF via

ps2pdf13 testpage-a4.ps

(this used the installed Ghostscript 8.63 for the conversion).

The PDF file was sent to CUPS via

lpr testpage-a4.pdf

On Hardy CUPS immediately converts the file to PostScript using the pdftops filter, on Intrepid the same conversion to PostScript happens in a later filtering step.

The other way to break it is to open the PDF file with evince on Hardy and printing it. In this case evince generates PostScript, using Poppler. CUPS passes this on in PostScript format.

One problem in evaluating the results is that the failure only happens with Brother printers. On the screen or on an HP printer the documents come out correctly.
Comment 3 Albert Astals Cid 2008-11-26 13:30:06 UTC
Wouldn't that be a bug in brother printers?
Comment 4 Adrian Johnson 2008-11-26 13:39:01 UTC
This still does not narrow it down enough. I'm not going to chase bugs across
multiple packages.

If there is a bug in poppler, and the comment about "only occurs on Brother
printers" leads me to believe the bug is not in poppler, you should be able to:

 - Provide a sample PDF that demonstrates the bug (small and simple is best)
 - Provide the pdftops command line options that you ran
 - Provide the PS output

And if the PS output from poppler renders fine in ghostscript and on HP
printers but breaks on Brother printers, finding out what it is in the PS
output that is causing the problem would help since the only thing I can test
PS on is ghostscript or a LaserJet printer.
Comment 5 Till Kamppeter 2008-11-27 02:30:24 UTC
The CUPS pdftops filter which is used here (Ubuntu Intrepid) is the one of CUPS 1.4 and this one is a simple wrapper around the /usr/bin/pdftops filter which comes with Poppler. The command line which CUPS uses with the Brother PPD (PostScript Level 3) is

pdftops -level3 -paperw <width> -paperh <height> <input file> -

So the for the attached PDF file (testpage-a4.pdf, evince displays it correctly) for example we would have

pdftops -level3 -paperw 595 -paperh 842 testpage-a4.pdf -

The output file is attached (testpage-a4-pstops.ps).

Version info:

till@till-laptop:~/ubuntu/cups/bzr/debian-trunk$ pdftops -v
pdftops version 3.00
Copyright 1996-2004 Glyph & Cog, LLC
till@till-laptop:~/ubuntu/cups/bzr/debian-trunk$ dpkg -l | grep libpoppler
...
ii  libpoppler3                                0.8.7-1                                 PDF rendering library
ii  poppler-utils                              0.8.7-1                                 PDF utilitites (based on libpoppler)
till@till-laptop:~/ubuntu/cups/bzr/debian-trunk$ 

I have also opened testpage-a4.pdf with evince and printed to a file, set A4 in the Page Setup and chosen PostScript as output format. The result I have attached as testpage-a4-evince.ps.
Comment 6 Till Kamppeter 2008-11-27 02:32:06 UTC
Created attachment 20625 [details]
Sample PDF file
Comment 7 Till Kamppeter 2008-11-27 02:33:46 UTC
Created attachment 20626 [details]
PostScript file resulting from conversion with pdftops
Comment 8 Till Kamppeter 2008-11-27 02:34:43 UTC
Created attachment 20627 [details]
PostScript file resulting from printing to file out of evince
Comment 9 Till Kamppeter 2008-11-27 02:55:34 UTC
Version info for evince:

till@till-laptop:~/ubuntu/cups/bzr/debian-trunk$ dpkg -l | grep evince
ii  evince                                     2.24.1-0ubuntu1                         Document (postscript, pdf) viewer
till@till-laptop:~/ubuntu/cups/bzr/debian-trunk$ dpkg -l | grep libcairo
...
ii  libcairo2                                  1.8.0-0ubuntu1                          The Cairo 2D vector graphics library
...
till@till-laptop:~/ubuntu/cups/bzr/debian-trunk$ 
Comment 10 Till Kamppeter 2008-11-27 02:58:53 UTC
Created attachment 20628 [details]
PPD file of one of the Brother printer for which the problem occurs
Comment 11 Adrian Johnson 2008-11-27 03:05:40 UTC
Do both testpage-a4-pdftops.ps and testpage-a4-evince.ps have the same offset problem on the Brother printer?

Comment 12 Till Kamppeter 2008-11-27 03:17:14 UTC
According to the Ubuntu bug report it seems to be the same, but I have asked the posters of the report now.
Comment 13 Adrian Johnson 2008-11-27 03:36:52 UTC
Both PS files display correctly in ghostscript (using either gv or evince). They also print correctly on my LaserJet. I manually verified the PostScript code that draws the outer box approximately 5 points from the edge of the page. It looks correct in both PS files.

It looks like the problem is in the Brother printer.

The only other thing I can suggest is to create the simplest possible PostScript file that draws a rectangle 5 points from the edge of the page. If that still reproduces the problem you have a broken (or misconfigured) printer.
Comment 14 Till Kamppeter 2008-11-27 03:56:06 UTC
PostScript files which are not generated from PDFs via Poppler, like the attached testpage-a4-orig.ps print correctly on Brother printers.
Comment 15 Till Kamppeter 2008-11-27 03:58:23 UTC
Created attachment 20629 [details]
PostScript file which was NOT created by converting a PDF with Poppler
Comment 16 Adrian Johnson 2008-11-27 04:12:51 UTC
Does the problem occur if the PS files are sent directly the the printer without going through any CUPS filters?
Comment 17 Till Kamppeter 2008-11-27 04:33:29 UTC
According to the Ubuntu bug report all PostScript files generated by Poppler from PDF files come out shifted, all others not, which would mean for the attached PostScript files that testpage-a4-pdftops.ps and testpage-a4-evince.ps come out shifted and testpage-a4-orig.ps not.

To be sure, I have asked the reporters of the Ubuntu bug now to print all the attached PostScript files without filtering and to tell which ones fail and which ones not.
Comment 18 James Cloos 2008-11-27 05:05:15 UTC
It might be useful to compare how gs renders the ps files with different
paper sizes and to compare that output with what the printers generate.

If you have a isplay at least 1200 px tall, compare:

gs -dBATCH -g794x1123 -r96 testpage-a4-orig.ps
gs -dBATCH -g816x1056 -r96 testpage-a4-orig.ps

If smaller try these instead:

gs -dBATCH -g595x842 -r72 testpage-a4-orig.ps
gs -dBATCH -g612x792 -r72 testpage-a4-orig.ps

In each pair the first renders the page on a4 sized (virtual) paper,
the second on usletter.

It may be the case that something in the poppler output confuses the
printer into thinking that the src is letter sized, causing it to
misprint to the a4 paper.

Just a supposition.

(Side note:  I'm sure I've read about similar bugs on Brother printers
             before.  Google may point to such discussions and perhaps
             to solutions.  The solution might just be to use PCL when
             printing to those printers, ignoring their PS capability.)
Comment 19 Till Kamppeter 2008-11-28 02:26:07 UTC
printer-internal settings on which paper size is in which tray are OK. One of the reporters of the Ubuntu bug has printed the three PostScript files attached to this bug without filtering and he gets shifted output only for the file generated by pdftops (testpage-a4-pdftops.ps).

The shift is 1.7 cm to the top, exactly the length difference between A4 and Letter paper.
Comment 20 Till Kamppeter 2008-11-28 02:57:13 UTC
Created attachment 20656 [details]
PostScript file resulting from conversion with pdftops from the XPDF package

Ubuntu Intrepid contains /usr/bin/pdftops in two packages: poppler-utils and xpdf-utils. By default the one from poppler-utils is installed. For testing I have switched to the one from xpdf-utils now and repeated the conversion of testpage-a4-orig.pdf with this version.

The resulting file (attached testpage-a4-pdftops-xpdf.ps) is only slightly different, but the page size is applied at one more point in the PostScript file:

--- testpage-a4-pdftops.ps	2008-11-27 11:20:22.000000000 +0100
+++ testpage-a4-pdftops-xpdf.ps	2008-11-28 11:42:28.000000000 +0100
@@ -1,4 +1,6 @@
 %!PS-Adobe-3.0
+% Produced by xpdf/pdftops 3.02
+%%Title: testpage-a4.ps
 %%LanguageLevel: 3
 %%DocumentSuppliedResources: (atend)
 %%DocumentMedia: plain 595 842 0 () ()
@@ -9,8 +11,8 @@
 %%PageMedia: plain
 %%EndDefaults
 %%BeginProlog
-%%BeginResource: procset xpdf 3.00 0
-%%Copyright: Copyright 1996-2004 Glyph & Cog, LLC
+%%BeginResource: procset xpdf 3.02 0
+%%Copyright: Copyright 1996-2007 Glyph & Cog, LLC
 /xpdf 75 dict def xpdf begin
 % PDF special state
 /pdfDictSize 15 def
@@ -737,6 +739,8 @@
 false op
 false OP
 {} settransfer
+0 0 595 842 re
+W
 q
 q
 [0.12 0 0 0.12 0 0] cm

Perhaps this version is better in convincing the printer to consider the paper as A4-sized.

pdftops of Poppler is version 3.0, of XPDF is version 3.02 ("pdftops -v").

I suggest to perhaps update Poppler's pdftops to this version.
Comment 21 Adrian Johnson 2008-11-28 03:02:53 UTC
(In reply to comment #19)
> printer-internal settings on which paper size is in which tray are OK. One of
> the reporters of the Ubuntu bug has printed the three PostScript files attached
> to this bug without filtering and he gets shifted output only for the file
> generated by pdftops (testpage-a4-pdftops.ps).
> 
> The shift is 1.7 cm to the top, exactly the length difference between A4 and
> Letter paper.
> 

Looking at the pdftops file that only thing that stands out is the
setpagedevice code in the pdfSetup procedure. 

Try removing line 719:

  595 842 false pdfSetup

This is setting the page size and the duplex option.
Comment 22 Adrian Johnson 2008-11-28 03:07:48 UTC
(In reply to comment #20)
> The resulting file (attached testpage-a4-pdftops-xpdf.ps) is only slightly
> different, but the page size is applied at one more point in the PostScript
> file:
[...]
> +0 0 595 842 re
> +W

All this is doing is clipping to a rectangle the size of the page. There is already another clip to the page size a bit further up so I am not sure what the benefit is.
Comment 23 Albert Astals Cid 2008-11-28 14:30:42 UTC
I'd really suggest to consult Brother Linux people if they exist, when i had a similar problem with HP they fixed their drivers in less than a week.
Comment 24 Adrian Johnson 2008-11-28 22:41:26 UTC
Doing a quick google search revealed an abundance of wrong page size problems with Brother printers. Some pages that provide solutions:

http://bbs.archlinux.org/viewtopic.php?id=55226
https://bugzilla.redhat.com/show_bug.cgi?id=230307
http://solutions.brother.com/linux/sol/printer/linux/printsetlpr.html
http://ubuntuforums.org/showpost.php?p=4763018&postcount=8

You could also try printing in PCL.
Comment 25 Till Kamppeter 2008-11-29 00:30:14 UTC
Thanks for the links, but all these links point to problems with Brother's proprietary PCL drivers, none has to do with the PostScript PPDs.
Comment 26 Menno Tjoelker 2008-11-30 03:37:00 UTC
Although the discussion about the proceedings might already have clarified, that the bug is NOT in the Brother driver, I have a real life proof for that: the problem occurs on my Xerox Phaser 6130 printer just as well. The errors are not as big as described above: the printout is slightly out of centre and a few millimeters are missing at the borders. (Since Firefox adds its own margins, the full page is printed in spite of the bug.)
Comment 27 Till Kamppeter 2008-12-16 15:38:32 UTC
Serge van Ginderachter has tested what is described in comment #20 and comment #21. In both cases his Brother printer still showed the problem. He sent the the jobs with the "nc" command to the printer, to avoid any additional filtering.
Comment 28 Adrian Johnson 2008-12-17 00:30:28 UTC
(In reply to comment #27)
> Serge van Ginderachter has tested what is described in comment #20 and comment
> #21. In both cases his Brother printer still showed the problem. He sent the
> the jobs with the "nc" command to the printer, to avoid any additional
> filtering.
> 

As that removed the only thing that had anything to do setting the page size I can not see anything else in the pdftops output that could cause this problem. The rest is all generic PostScript that does not have anything to do with the page size.

At this point I would recommend contacting Brother. They should be able to either confirm it is a printer bug or tell us what specifically in the pdf2ps output the Brother printers don't like. I can not see anything here that is pointing to a poppler bug.

Your only other option is to trim the PostScript file down until you find the minimal bit of PostScript that triggers the bug. Contacting Brother would be the easier option.
Comment 29 Adrian Johnson 2008-12-17 00:44:02 UTC
(In reply to comment #26)
> Although the discussion about the proceedings might already have clarified,
> that the bug is NOT in the Brother driver, I have a real life proof for that:
> the problem occurs on my Xerox Phaser 6130 printer just as well. The errors are
> not as big as described above: the printout is slightly out of centre and a few
> millimeters are missing at the borders. (Since Firefox adds its own margins,
> the full page is printed in spite of the bug.)
> 

This bug is about Letter size paper being selected instead of A4 resulting in a 1.7cm shift (exactly the difference between the height of A4 and Letter). If you are seeing a different shift it is not the same issue.

If you think you are having the same problem, try printing the test cases attached to this bug and tell is what the results are. Note that you must bypass all CUPS filtering as described at:

  https://bugs.launchpad.net/ubuntu/+source/foomatic-db/+bug/293832/comments/37

to guarantee that the test file is not modified on its way to the printer.
Comment 30 Björn Steinbrink 2009-12-14 06:27:15 UTC
After some hours of googling, I finally found the culprit: The PageSize policy setting.

See the patch attached in this bug report against IceApe:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=469266

This bug report also claims that the PageSize policy is to be blamed:
https://bugs.freedesktop.org/show_bug.cgi?id=17952

But setting it to 1 didn't work for me (Brother HL-5150D). Simply removing the "/Policies ... /PageSize ..." line from the prolog in the testpage-a4-pdftops.ps testcase causes the printout to be correct.
Comment 31 impulze 2010-10-17 14:52:41 UTC
The patch applied to Ubuntu Lucid and proposed in:
https://bugs.launchpad.net/ubuntu/+source/poppler/+bug/293832/comments/107
fixed the very same issue for me with a Brother MFC 7820N.
Any comments on the validity and correctness of the patch so we might get it fixed in poppler if it's really not a driver issue?
Comment 32 GitLab Migration User 2018-08-21 10:56:42 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/poppler/poppler/issues/439.
Comment 33 Elanie 2018-10-23 10:04:08 UTC Comment hidden (spam)
Comment 34 Thomas Capricelli 2018-10-23 10:23:17 UTC
Spam alert ...


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.