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

Albert Astals Cid aacid at kde.org
Wed Oct 28 13:57:29 PDT 2015


El Wednesday 28 October 2015, a les 10:23:11, Martin Pahl va escriure:
> The main problem with setting the option fit-to-page in okular
> unconditionally is that it's impossible to print true to scale anymore.
> That renders okular nearly useless for printing. 

You mean "for your printing needs", some other people would argue that most 
users want the thing they print to fit in the paper they're using, and to be 
honest "fit to paper" is evinces default print mode too.

Anyhow any talk about okular is off topic here, if you want to help with the 
development join okular-devel 
  https://mail.kde.org/mailman/listinfo/okular-devel

If you want to file a bug, that's also welcome but less likely to yield 
results.

Cheers,
  Albert

> A quick patch is to open
> /usr/lib64/libokularcore.so.6.0.0 with an binary editor e.g. okteta, find
> the string fit-to-page and replace the leading 'f' with 0. It's an ugly
> patch but after that okular is useable again ;).
> 
> Did you report this bug already? I wasn't sure where to report it, because I
> think it's a problem of a missing feature in the print-dialog as well. To
> my understanding the print-dialog is part of Qt.
> 
> Regards,
> 
> Martin Pahl
> 
> Am Dienstag, 27. Oktober 2015, 18:36:35 schrieb Stefan Brandner:
> > I checked the okular source file which is responsible for printing ->
> > fileprinter.cpp
> > http://quickgit.kde.org/?p=okular.git&a=blob&h=55977a1bad711f9f1dcc38671a2
> > 5a
> > ea5c10ec4c2&hb=c743eceb3d7eee02e6d0726b6e90acb6112ea6bf&f=core%2Ffileprin
> > ter .cpp The fit-to-page was added by Albert Astals Cid on Wed, 10 Oct
> > 2012 with the fix name:
> > Fix printing contiguous selected pages with bookmarks
> > 
> > The printing direct to a printer is done with the lpr command plus
> > arguments.
> > But this works from the command line so I compared the cups debug
> > messages.
> > 
> >  From the cups debug when printing with okular pdftops is used as
> > 
> > follwoing. The printout is not ok!
> > 
> >   [05/Dec/2014:11:27:32 +0100] [Job 10] Started filter
> > 
> > /usr/lib/cups/filter/pstops (PID 25207)
> > I [05/Dec/2014:11:27:32 +0100] [Job 10] Started backend
> > /usr/lib/cups/backend/cups-pdf (PID 25208)
> > D [05/Dec/2014:11:27:32 +0100] Discarding unused job-state-changed
> > event...
> > D [05/Dec/2014:11:27:32 +0100] Returning IPP successful-ok for
> > Send-Document (ipp://localhost:631/printers/CUPS-PDF) from localhost
> > D [05/Dec/2014:11:27:32 +0100] cupsdSetBusyState: newbusy="Printing jobs
> > and dirty files", busy="Active clients and dirty files"
> > D [05/Dec/2014:11:27:32 +0100] cupsdReadClient: 14 WAITING Closing on EOF
> > D [05/Dec/2014:11:27:32 +0100] cupsdCloseClient: 14
> > D [05/Dec/2014:11:27:32 +0100] cupsdSetBusyState: newbusy="Printing jobs
> > and dirty files", busy="Printing jobs and dirty files"
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] Page = 595x842; 0,0 to 595,842
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] slow_collate=0, slow_duplex=0,
> > slow_order=0
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] Before copy_comments -
> > %!PS-Adobe-3.0
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] %!PS-Adobe-3.0
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] %Produced by poppler pdftops
> > version: 0.26.5 (http://poppler.freedesktop.org)
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] %%Creator: pdftk 2.02 -
> > www.pdftk.com
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] %%Title: Dirichlet.pdf
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] %%LanguageLevel: 2
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] %%DocumentSuppliedResources:
> > (atend) D [05/Dec/2014:11:27:32 +0100] [Job 10] %%DocumentMedia: A4 595
> > 842 0 () () D [05/Dec/2014:11:27:32 +0100] [Job 10] %%BoundingBox: 0 0
> > 595 842 D [05/Dec/2014:11:27:32 +0100] [Job 10] %%Pages: 2
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] %%EndComments
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] Before copy_prolog -
> > %%BeginDefaults D [05/Dec/2014:11:27:32 +0100] [Job 10] Before copy_setup
> > - %%BeginSetup D [05/Dec/2014:11:27:32 +0100] [Job 10] Before page loop -
> > %%Page: 1 1 D [05/Dec/2014:11:27:32 +0100] [Job 10] Copying page 1...
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] PAGE: 1 1
> > D [05/Dec/2014:11:27:32 +0100] Discarding unused job-progress event...
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] pagew = 575.0, pagel = 822.0
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] bboxx = 0, bboxy = 0, bboxw =
> > 311, bboxl = 542
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] PageLeft = 10.0, PageRight = 585.0
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] PageTop = 832.0, PageBottom = 10.0
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] PageWidth = 595.0, PageLength =
> > 842.0
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] Copying page 2...
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] PAGE: 2 1
> > D [05/Dec/2014:11:27:32 +0100] Discarding unused job-progress event...
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] pagew = 575.0, pagel = 822.0
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] bboxx = 0, bboxy = 0, bboxw =
> > 317, bboxl = 548
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] PageLeft = 10.0, PageRight = 585.0
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] PageTop = 832.0, PageBottom = 10.0
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] PageWidth = 595.0, PageLength =
> > 842.0
> > D [05/Dec/2014:11:27:32 +0100] [Job 10] Wrote 2 pages...
> > D [05/Dec/2014:11:27:32 +0100] PID 25207 (/usr/lib/cups/filter/pstops)
> > exited with no errors.
> > D [05/Dec/2014:11:27:39 +0100] PID 25208
> > (/usr/lib/cups/backend/cups-pdf) exited with no errors.
> > 
> > When printing from the console which works it does additional a pdftopdf.
> > 
> > I [27/Oct/2015:18:22:08 +0100] [Job 833] Started filter
> > /usr/lib/cups/filter/pdftopdf (PID 13386)
> > I [27/Oct/2015:18:22:08 +0100] [Job 833] Started filter
> > /usr/lib/cups/filter/pdftops (PID 13387)
> > I [27/Oct/2015:18:22:08 +0100] [Job 833] Started backend
> > /usr/lib/cups/backend/cups-pdf (PID 13388)
> > D [27/Oct/2015:18:22:08 +0100] Discarding unused job-state-changed
> > event...
> > D [27/Oct/2015:18:22:08 +0100] [Client 3] Returning IPP successful-ok
> > for Send-Document (ipp://localhost:631/printers/CUPS-PDF) from localhost
> > D [27/Oct/2015:18:22:08 +0100] [Client 3] Content-Length: 171
> > D [27/Oct/2015:18:22:08 +0100] [Client 3] cupsdSendHeader: code=200,
> > type="application/ipp", auth_type=0
> > D [27/Oct/2015:18:22:08 +0100] [Client 3] con->http=0x7f51a291c960
> > D [27/Oct/2015:18:22:08 +0100] [Client 3] cupsdWriteClient error=0,
> > used=0, state=HTTP_STATE_POST_SEND, data_encoding=HTTP_ENCODING_LENGTH,
> > data_remaining=171, response=0x7f51a29208b0(IPP_STATE_DATA), pipe_pid=0,
> > file=-1
> > D [27/Oct/2015:18:22:08 +0100] [Client 3] Writing IPP response,
> > ipp_state=IPP_STATE_DATA, old wused=0, new wused=0
> > D [27/Oct/2015:18:22:08 +0100] [Client 3] bytes=0, http_state=0,
> > data_remaining=171
> > D [27/Oct/2015:18:22:08 +0100] [Client 3] Flushing write buffer.
> > D [27/Oct/2015:18:22:08 +0100] [Client 3] New state is HTTP_STATE_WAITING
> > D [27/Oct/2015:18:22:08 +0100] [Client 3] Waiting for request.
> > D [27/Oct/2015:18:22:08 +0100] cupsdSetBusyState: newbusy="Printing jobs
> > and dirty files", busy="Active clients and dirty files"
> > D [27/Oct/2015:18:22:08 +0100] [Client 3] HTTP_STATE_WAITING Closing for
> > error 32 (Broken pipe)
> > D [27/Oct/2015:18:22:08 +0100] [Client 3] Closing connection.
> > D [27/Oct/2015:18:22:08 +0100] cupsdSetBusyState: newbusy="Printing jobs
> > and dirty files", busy="Printing jobs and dirty files"
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] pdftops - copying to temp print
> > file "/var/spool/cups/tmp/0344b5639e88d"
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] PID 13386
> > (/usr/lib/cups/filter/pdftopdf) exited with no errors.
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Printer make and model: Generic
> > CUPS v1.1
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Running command line for
> > pstops: pstops 833 stefan Dirichlet.pdf 1 'finishings=3
> > job-uuid=urn:uuid:83106b75-7a24-3dda-5d74-16fc30766fd6
> > job-originating-host-name=localhost date-time-at-creation=
> > date-time-at-processing= time-at-creation=1445966528
> > time-at-processing=1445966528 document-name-supplied=Dirichlet.pdf'
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Using image rendering
> > resolution 300 dpi
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Running command line for
> > pdftops: pdftops -level2 -origpagesizes -nocenter -r 300
> > /var/spool/cups/tmp/0344b5639e88d -
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Started filter pdftops (PID
> > 13392)
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Started filter pstops (PID 13393)
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Page = 595x842; 0,0 to 595,842
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] slow_collate=0, slow_duplex=0,
> > slow_order=0
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Before copy_comments -
> > %!PS-Adobe-3.0
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] %!PS-Adobe-3.0
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] %Produced by poppler pdftops
> > version: 0.26.5 (http://poppler.freedesktop.org)
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] %%Creator: pdftk 2.02 -
> > www.pdftk.com
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] %%LanguageLevel: 2
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] %%DocumentSuppliedResources:
> > (atend)
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] %%DocumentMedia: A4 595 842 0 ()
> > () D [27/Oct/2015:18:22:08 +0100] [Job 833] %%BoundingBox: 0 0 595 842 D
> > [27/Oct/2015:18:22:08 +0100] [Job 833] %%Pages: 2
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] %%EndComments
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Before copy_prolog -
> > %%BeginProlog
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Before copy_setup - %%BeginSetup
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Before page loop - %%Page: 1 1
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Copying page 1...
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] PAGE: 1 1
> > D [27/Oct/2015:18:22:08 +0100] cupsdMarkDirty(---J-)
> > D [27/Oct/2015:18:22:08 +0100] cupsdSetBusyState: newbusy="Printing jobs
> > and dirty files", busy="Printing jobs and dirty files"
> > D [27/Oct/2015:18:22:08 +0100] cupsdMarkDirty(---J-)
> > D [27/Oct/2015:18:22:08 +0100] cupsdSetBusyState: newbusy="Printing jobs
> > and dirty files", busy="Printing jobs and dirty files"
> > D [27/Oct/2015:18:22:08 +0100] Discarding unused job-progress event...
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] pagew = 595.0, pagel = 842.0
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] bboxx = 0, bboxy = 0, bboxw =
> > 595, bboxl = 842
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] PageLeft = 0.0, PageRight = 595.0
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] PageTop = 842.0, PageBottom = 0.0
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] PageWidth = 595.0, PageLength =
> > 842.0
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Copying page 2...
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] PAGE: 2 1
> > D [27/Oct/2015:18:22:08 +0100] cupsdMarkDirty(---J-)
> > D [27/Oct/2015:18:22:08 +0100] cupsdSetBusyState: newbusy="Printing jobs
> > and dirty files", busy="Printing jobs and dirty files"
> > D [27/Oct/2015:18:22:08 +0100] cupsdMarkDirty(---J-)
> > D [27/Oct/2015:18:22:08 +0100] cupsdSetBusyState: newbusy="Printing jobs
> > and dirty files", busy="Printing jobs and dirty files"
> > D [27/Oct/2015:18:22:08 +0100] Discarding unused job-progress event...
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] pagew = 595.0, pagel = 842.0
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] bboxx = 0, bboxy = 0, bboxw =
> > 595, bboxl = 842
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] PageLeft = 0.0, PageRight = 595.0
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] PageTop = 842.0, PageBottom = 0.0
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] PageWidth = 595.0, PageLength =
> > 842.0
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] Wrote 2 pages...
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] PID 13392 (pdftops) exited with
> > no errors.
> > D [27/Oct/2015:18:22:08 +0100] [Job 833] PID 13393 (pstops) exited with
> > no errors.
> > 
> > Here I need help again. Is this a cups problem?
> > 
> > Regards
> > Stefan
> > 
> > Am 27.10.2015 um 13:38 schrieb Adrian Johnson:
> > > On 25/10/15 21:08, Stefan Brandner wrote:
> > >> I want to summarize how the problem appears when printing the file
> > >> Dirichlet.pdf with okular.
> > >> Find the file at:
> > >> https://bugzilla.opensuse.org/attachment.cgi?id=616147
> > >> 
> > >> 1. with OpenSuse 13.1 and okular 4.11.2 the CUPS command was without
> > >> the
> > >> fit-to-page option
> > >> following commands are executed:
> > >> pdftops Dirichlet.pdf
> > >> lpr Dirichlet.ps
> > >> The file was printed unscaled but centered and the printout was useful.
> > >> 
> > >> 2. with the actual OpenSuse 13.2 and okular 4.14.9 the CUPS command is
> > >> now with fit-to-page and then the file is shifted to the right with
> > >> half
> > >> of the text cut
> > >> this can be reproduced with following commands:
> > >> pdftops Dirichlet.pdf
> > >> lpr -o fit-to-page Dirichlet.ps
> > >> This does not work since the BoundingBox values are incorrect.
> > >> See explanation at CUPS documentation:
> > >> http://www.cups.org/documentation.php/options.html
> > > 
> > > I'm not sure which application is enabling the fit-to-page or why it
> > > changed. The fit to page would be better performed in pdftops which
> > > already has this capability. The problem with performing a fit-to-page
> > > based on the PS output is the Adobe Document Structuring Conventions
> > > define the BoundingBox to be the smallest box that encloses all marks on
> > > the page.
> > > 
> > > A PS file with correctly calculated PageBoundingBox comments is likely
> > > have a different bounding box on each page depending on the content. If
> > > fit-to-page is applied based on the bounding box, each page will have a
> > > different scale factor applied. A blank page with just a page number at
> > > the bottom will be scaled up to fit the page number to the entire page.
> > > This is probably not what you want.
> > > 
> > > The fit-to-page feature relies on the fact that a lot of applications
> > > just set the bounding box to the page size since computing the ink
> > > extents of all marks on the page is not trivial.
> > > 
> > > If a future version of poppler tightened up the PageBoundingBox to make
> > > it more correct you may find this workflow which relies on an incorrect
> > > interpretation of the BoundingBox comment may no longer work for you.
> > > 
> > >> -----------------------------------------------------------------------
> > >> --
> > >> -----
> > >> 
> > >> Scaling to Fit
> > >> 
> > >> The -o fit-to-page option specifies that the document should be scaled
> > >> 
> > >> to fit on the page:
> > >>    lp -o fit-to-page filename
> > >>    lpr -o fit-to-page filename
> > >> 
> > >> The default is to use the size specified in the file.
> > >> 
> > >> This feature depends upon an accurate size in the print file.
> > >> If no size is given in the file, the page may be scaled incorrectly!
> > >> -----------------------------------------------------------------------
> > >> --
> > >> -----
> > >> 
> > >> 
> > >> As mentioned in the opensuse bug:
> > >> https://bugzilla.opensuse.org/show_bug.cgi?id=908624
> > >> ghostscript shows Bounding Box values that do work.
> > >> 
> > >> Martin Pahl wrote a fix that calculates the correct page bounding
> > >> values.
> > >> With this fix above commands work without problem.
> > >> 
> > >> 3. another solution for the printing with okular would be calling
> > >> pdftotops -expand Dirichlet.pdf
> > >> lpr -o fit-to-page Dirichlet.ps
> > >> 
> > >> 4. also a lpr Dirichlet.pdf from the command line is working but this
> > >> it
> > >> is not the way as it is executed with okular
> > >> 
> > >> 5. since it is not possible to disable the fit-to-page inside okular,
> > >> all printouts of files with wrong BoundingBox values are scrap!!!
> > >> 
> > >> 6. the ideal place to fix this is may be somewhere else but the
> > >> solution
> > >> from Martin fixes it for okular.
> > >> 
> > >> 7. I had many files with this problems and since I am using the patch
> > >> all my printing problems are gone
> > >> 
> > >> Regards
> > >> Stefan
> > >> 
> > >> _______________________________________________
> > >> 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



More information about the poppler mailing list