[poppler] Printing of certain PDF files does not work with "fit-to-page" because of wrong BoundingBox values in the PostScript

Martin Pahl Bugzilla at pahlx.de
Fri Oct 23 08:43:27 PDT 2015


Ok, I can not review my own code, but I will try to explain, what I changed. 
The patch might look bigger than it actually is. This is because I had to 
restructure the code a little bit, because in the original calculation of 
bounding box and output to the postscript file is mixed. But to know the 
PageBoundingBox you have to first transform the origincal bounding box of the 
object to the output media coordinates. In the end my code only touches the 
calculation of the PageBoundingBox. Nothing else is changed.

So lets start (o-prefix = original linenumbers, p-prefix = patched 
linenummbers):

In line p3678 I introduced and initialized two variables pbbtx and pbbty to 
save the page bounding box translation.

>From line o3765 - o3800 (p3772-p3793) I removed every writePS-command to do 
that after calculation of page bounding box translation. I also changed the 
chain of if-clauses into one switch statement.  

Starting in line p3818 the the translation of page bounding box is calculated. 
The result is stored in the new variables pbbtx and pbbty. In the original 
code these values are immediately added to tx and ty. But we need these values 
later on. So we store them and add them to tx and ty in line p3636 and p3637. 
So after all the value of tx and ty are the same as before. 

>From line p3839 the result is written to the PS file. 

Hope this explanation helps a little bit to understand the code. The patch to 
the newest version of poppler is added in the attachement.

Regards,

Martin Pahl

P.S. I used the old fashioned xfig to produce pdf files that show this bug, 
because xfig produced pdf with a media size identical to the size of the figure. 
I can generate an example pdf and corresponding ps files next week.

Am Freitag, 23. Oktober 2015, 00:05:07 schrieb William Bader:
> I can look at the C++ code to check that the code does what it claims to do.
> I think that what it claims to do is correct, but I work mostly with single
> page documents, so someone who knows more about DSCs should look at that.
> Regards,William
> 
> > From: aacid at kde.org
> > To: poppler at lists.freedesktop.org
> > Date: Fri, 23 Oct 2015 00:02:01 +0200
> > Subject: Re: [poppler] Printing of certain PDF files does not work
> > with	"fit-to-page" because of wrong BoundingBox values in the PostScript> 
> > El Thursday 22 October 2015, a les 04:12:41, William Bader va escriure:
> > > Hi Stefan,
> > > 
> > > I am a poppler user, not a popper maintainer. I can't push changes.
> > > Sorry.
> > 
> > But you can review them. Pushing is very easy, it's the review part that
> > is
> > hard.
> > 
> > Cheers,
> > 
> >   Albert
> >   
> > > Regards,
> > > William
> > > 
> > > From: stefan.brandner at gmx.at
> > > To: williambader at hotmail.com; poppler at lists.freedesktop.org
> > > Subject: Aw: RE: [poppler] Printing of certain PDF files does not work
> > > with
> > > "fit-to-page" because of wrong BoundingBox values in the PostScript
> > > Date:
> > > Thu, 22 Oct 2015 09:18:11 +0200
> > > 
> > > 
> > > This printing problem appear at pdf files which are coming from scanner.
> > > 
> > > Since years there are reports of this problem:
> > > 
> > > https://forum.kde.org/viewtopic.php?f=20&t=97572
> > > 
> > > https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=761487
> > > 
> > > https://bugs.kde.org/show_bug.cgi?id=338456
> > > 
> > > https://bugs.kde.org/show_bug.cgi?id=195719
> > > 
> > > 
> > > 
> > > 
> > > We now found the root cause and have a fix.
> > > 
> > > 
> > > 
> > > So if Albert has no time at all I wonder if you (William) can take over
> > > this solution and push it.
> > > 
> > > As Martin Pahl wrote he is willing to support and explain his code.
> > > 
> > > 
> > > 
> > > Regards
> > > 
> > > Stefan
> > > 
> > > 
> > > 
> > > 
> > > Gesendet: Mittwoch, 21. Oktober 2015 um 01:44 Uhr
> > > 
> > > Von: "William Bader" <williambader at hotmail.com>
> > > 
> > > An: "Stefan Brandner" <stefan.brandner at gmx.at>,
> > > "poppler at lists.freedesktop.org" <poppler at lists.freedesktop.org>
> > > 
> > > Betreff: RE: [poppler] Printing of certain PDF files does not work with
> > > "fit-to-page" because of wrong BoundingBox values in the PostScript
> > > 
> > > 
> > > 
> > > 
> > > The Adobe document  5001.DSC_Spec.pdf "PostScript Language Document
> > > Structuring Conventions Specification" Version 3.0, 25 September 1992,
> > > says
> > > on page 39 about the BoundingBox comment:
> > > 
> > > 
> > > "This comment specifies the bounding box that encloses all marks painted
> > > on
> > > all pages of a document. That is, it must be a “high water mark” in all
> > > directions for marks made on any page. The four arguments correspond to
> > > the
> > > lower left ( llx , lly ) and upper right corners ( urx , ury ) of the
> > > bounding box in the default user coordinate system (PostScript units)."
> > > 
> > > 
> > > 
> > > and gives an example where the BoundingBox is the smallest rectangle
> > > that
> > > covers the PageBoundingBoxes of the pages in the document.
> > > 
> > > 
> > > 
> > > If you are worried about breaking things that depend on the current
> > > behavior of pdftops, would it work to add a command line option? 
> > > pdftops already has -origpagesize and -nocrop options.
> > > 
> > > 
> > > 
> > > Regards,
> > > 
> > > William
> > > 
> > > 
> > > 
> > > To: poppler at lists.freedesktop.org
> > > 
> > > From: stefan.brandner at gmx.at
> > > 
> > > Date: Tue, 20 Oct 2015 19:02:03 +0200
> > > 
> > > Subject: [poppler] Printing of certain PDF files does not work with
> > > "fit-to-page" because of wrong BoundingBox values in the PostScript
> > > 
> > > 
> > > 
> > > I am using the patch now for several month and I can prove it is working
> > > fine. So if the code quality is ok for you Albert why not pushing it?
> > > 
> > > Regards
> > > Stefan Brandner
> > > 
> > > El Dijous, 7 de maig de 2015, a les 09:34:09, Martin Pahl va escriure:
> > > > Hi,
> > > > 
> > > > I sent patches to fix the bug:
> > > > 
> > > > https://bugs.freedesktop.org/show_bug.cgi?id=87161
> > > > 
> > > > Those patches were automatically sent to poppler-bugs mailing list.
> > > > But as
> > > > I see no reaction to my patch submission (poppler-bugs seems to be a
> > > > mailinglist without human interaction)  I just want to ask, what is
> > > > the
> > > > right way to submit patches.
> > > 
> > > It is.
> > > 
> > > What we need is more people with time to review patches.
> > > 
> > > Cheers,
> > > 
> > >   Albert
> > >   
> > > > By the way this bug is really annoying as it makes all PDF viewers
> > > > using
> > > > poppler useless for printing documents that do not have the page size
> > > > of
> > > > the output device (e.g. printer). On the other hand acroread is not an
> > > > alternative anymore as Adobe has discontinued support for Linux.
> > > > 
> > > > Regards,
> > > > 
> > > > Martin Pahl
> > > 
> > > _______________________________________________ poppler mailing list
> > > poppler at lists.freedesktop.org
> > > http://lists.freedesktop.org/mailman/listinfo/poppler
> > 
> > _______________________________________________
> > poppler mailing list
> > poppler at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/poppler
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch-remotes_origin_master
Type: text/x-patch
Size: 4583 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20151023/03ca12e8/attachment.bin>


More information about the poppler mailing list