On Linux I'm using the mupdf library to convert a pdf to a png using the mudraw command:
mudraw -o thefile.png thefile.pdf 1
This normally works perfectly fine, but for one pdf I get the following output:
error: cannot find ExtGState dictionary
error: cannot set graphics state
warning: Ignoring errors during rendering
error: cannot find XObject dictionary when looking for: 'R132'
error: cannot draw xobject/image
Since I had never heard of ExtGState
I looked it up and according to the PDF specs, "it specifies a PDEElement object's extended graphics state, which is part of its graphics state", or according to a post here on SO "It specifies a function that should be used for processing colors or color components".
I also found the line of C-code on which the error gets thrown, but since my C skills are not so well, and my knowledge of the PDF specifications even worse I don't really have a clue what the source of the trouble is.
Could anybody shed some more light on this error, and possibly point my in the direction of a solution? All tips are welcome!
[EDIT] The file which is giving me trouble can be downloaded here.
Sounds like your PDF file is broken. As yms said, post an example file
[edit] The file contains a Form XObject:
141 0 obj
<<
/FormType 1
/Subtype /Form
/Type /XObject
/BBox [ 2972.77002 2600.78003 6097.58008 3245.17993 ]
/Matrix [ 1 0 0 1 0 0 ]
/Length 91
/Group 138 0 R
>>
This does not include a Resources entry, so any objects defined by reference will have to inherit from the parent Resources. The stream is :
stream
/R131 gs
q
2980 1958.9 2700 1340 re W n
q 3124.8 0 0 644.4 2972.78 2600.78 cm
/R132 Do
Q
Q
endstream
Notice that this uses two named objects /R131 and /R132. From context we can see that R131 is a graphics state (an ExtGState in fact) and R132 is an XObject (either an image or a form).
This form appears to be used only as a Group in a couple of places, both times for an SMask. One of those is from the Page object, as a ExtGState, the other, although defined doesn't appear to be used at all (its legal to have unused objects in a PDF file)
So its only used once, from the Page object. Since the Form XObject doesn't have a Resources dictionary we consult its parent (the main Page) which does have a Resources dictionary. But that Resources dictionary does not define the named objects R131 or R132. This means that MuPDF can't find those objects, so it can't use them.
So essentially your PDF file is invalid. It will render (MuDraw does render a PNG file from it), but the result may not be what was intended. There's no way for me to tell.
Note that Adobe Acrobat also throws an error viewing this PDF file.
Assuming you really did use Ghostscript to create this file (which is what the Producer metadata says) my recommendation is that you upgrade to something rather more recent. The current version is 9.18, this was created using 9.10 whcih is 2 years old. However the file has also been modified using something called TCT 5.7.0.1 which I've not previously heard of. It may be that this modification is what broke the file, I can't tell.