Bug 693205 - Attached PDF file is rendered with 0x0 page size
Summary: Attached PDF file is rendered with 0x0 page size
Status: RESOLVED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PDF Interpreter (show other bugs)
Version: 9.05
Hardware: PC Linux
: P4 normal
Assignee: Alex Cherepanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-22 19:09 UTC by Till Kamppeter
Modified: 2012-07-23 13:53 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
b1.pdf (1.03 MB, application/pdf)
2012-07-22 19:09 UTC, Till Kamppeter
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Till Kamppeter 2012-07-22 19:09:54 UTC
Created attachment 8781 [details]
b1.pdf

See following Debian bug report:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=611993

The user has an ImageMagick-generated PDF file (attached) which Ghostscript is not able to display or convert into PostScript. evince (Poppler) displays it without problems.

Simple

gs b1.pdf

errors out with an X error, probably trying to create a window with zero size.

gv b1.pdf

displays a page with zero size (and therefore naturally without content).

gs -sDEVICE=bbox b1.pdf

shows a zero-sized bounding box.
Comment 1 Alex Cherepanov 2012-07-22 22:58:35 UTC
What else Ghostscript can do?

The sample file tries to set rather small page size.
/MediaBox [0 0 0.00108919 0.00181758]
Comment 2 roucaries.bastien+gs 2012-07-23 10:10:23 UTC
(In reply to comment #1)
> What else Ghostscript can do?
> 
> The sample file tries to set rather small page size.
> /MediaBox [0 0 0.00108919 0.00181758]

- first solve the crash in X by rounding up instead of having  zero size windows.
- second at your whish:
* do like plopper in this case
* error out with an meaningful error

Bastien
Comment 3 Chris Liddell (chrisl) 2012-07-23 10:36:17 UTC
(In reply to comment #2)
> 
> - first solve the crash in X by rounding up instead of having  zero size
> windows.

There is no "crash" in X - there is an exit with an error condition, and a meaningful error message from the library which triggered the error.

> - second at your whish:
> * do like plopper in this case

Poppler is not following the spec, and that strikes me as bad.

> * error out with an meaningful error

There is no error, from our point-of-view. For both PDF and Postscript 0 x 0 are valid (if pointless) page dimensions, thus we accept the size request.

0 x 0 is not a valid window size for X, thus the X library throws an error, with a meaningful error message. The X error does cause an "exit" to occur (in the X library, which is poor form, IMHO), so there's not much "recovery" we can do, from that stage.
Comment 4 roucaries.bastien+gs 2012-07-23 11:36:36 UTC
(In reply to comment #3)
> (In reply to comment #2)
> > 
> > - first solve the crash in X by rounding up instead of having  zero size
> > windows.
> 
> There is no "crash" in X - there is an exit with an error condition, and a
> meaningful error message from the library which triggered the error.
> 
> > - second at your whish:
> > * do like plopper in this case
> 
> Poppler is not following the spec, and that strikes me as bad.
> 
> > * error out with an meaningful error
> 
> There is no error, from our point-of-view. For both PDF and Postscript 0 x 0
> are valid (if pointless) page dimensions, thus we accept the size request.
> 
> 0 x 0 is not a valid window size for X, thus the X library throws an error,
> with a meaningful error message. The X error does cause an "exit" to occur (in
> the X library, which is poor form, IMHO), so there's not much "recovery" we can
> do, from that stage.

Ok the poor form could be solved with XSetErrorHandler/XSetIOErrorHandler.

About poppler, it crash the first time I submit this file. Thus they solve half part of the problem. Will resubmit  bug with non conformant behavior.

Could I copy your comment to the poppler bug report ?

Bastien
Comment 5 Chris Liddell (chrisl) 2012-07-23 11:50:05 UTC
(In reply to comment #4)
> 
> Ok the poor form could be solved with XSetErrorHandler/XSetIOErrorHandler.

True, but what would we gain? At the moment you get a fairly clear error message from the source of the error. All we could really do would be print some other message, and exit somewhere else......

> 
> About poppler, it crash the first time I submit this file. Thus they solve half
> part of the problem. Will resubmit  bug with non conformant behavior.
> 
> Could I copy your comment to the poppler bug report ?


You can if you like. I suspect their (quite reasonable) position will be: it's a dumb thing to do, we're not going to lose sleep over it.

Chris
Comment 6 Chris Liddell (chrisl) 2012-07-23 13:53:40 UTC
I've added code to check the requested pagesize and, if it's zero (or less!) in either dimension, inform the user, and return a rangecheck error, before we pass the request to X.

http://git.ghostscript.com/?p=ghostpdl.git;a=commitdiff;h=f661e522