Click to See Complete Forum and Search --> : Ghostscript fails to read PDF, strange error...


Stween
07-18-2004, 03:25 PM
This is an irritation that's been getting at me for some time. I tend to view PDF and postscript files using the nice little viewer 'gv'. However, since installing Debian unstable a while back, gv has been giving me strange errors. Sometimes I've worked around this problem by using pdf2ps to convert the PDF to a postscript file, and then opening it, but it certainly doesn't always work.

For one file I have here just now, gv told me:
Error: /syntaxerror in readxref
Operand stack:

Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2\
%stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push\
1 3 %oparray_pop 1 3 %oparray_pop 1 3 %oparray_pop --nostringval-- --nostringval-- \
--nostringval-- --nostringval-- --nostringval-- --nostringval--
Dictionary stack:
--dict:1048/1123(ro)(G)-- --dict:0/20(G)-- --dict:74/200(L)-- --dict:74/200(L)-- \
--dict:100/127(ro)(G)-- --dict:230/230(ro)(G)-- --dict:14/15(L)--
Current allocation mode is local
GPL Ghostscript 8.01: Unrecoverable error, exit code 1

And for the same file, pdf2ps gave me the same error (so the ghostscript libraries were presumably pumping this error out...)

Any Google searches I tried were fairly useless, this doesn't appear to be a problem many people have encountered before. I know I've certainly never seen it!

I'd probably let it lie if it just happened for one or two PDF's ... instead, this happens on all PDF's I try to open. I quickly decided to see if I needed to update my ghostscript libraries, but apparently not. I tried an 'apt-get install gs-afpl', which wasn't installed. I can open some PDF's now, but all are preceded by the error:
**** Warning: An error occurred while reading an XREF table.
**** The file has been damaged. This may have been caused
**** by a problem while converting or transfering the file.
**** Ghostscript will attempt to recover the data.... basically, I'm confused :) Does anybody have any idea why this might be broken, and how I might fix it?


Cheers,
Stween

JohnT
07-18-2004, 07:01 PM
No idea if this is on the right track, but its food for thought.
http://www.cups.org/ghostscript.php


Thought this part was interesting (just what bug-fixes??):
These updates incorporate bug fixes
to the current GNU version of Ghostscript
as well as the latest CUPS, GIMP-print, and
other add-ons to Ghostscript.

Stween
07-24-2004, 08:47 AM
I've tried the gs-esp package, with no joy.

The Debian gs packages listed when I search here are: gs, gs-common, gs-esp, gs-gpl, gs-afpl.

gs-common is required, and gs-gpl is the "recommended" ghostscript postscript interpreter to sit on top of that. 'gs' seems to be a placeholder, that isn't required, and can be safely removed.

It seems that the error occurs when running pdf2dsc, to convert a PDF to something which ghostscript can view quite happily.

To ensure that I hadn't just messed something up (which was possible, since I was toying with the different gs-* packages for some time), I removed 'gs-common', and therefore everything which depended on it. I then installed 'gv', and so gs-common and gs-gpl. pdf2dsc still gives me errors for these files, of the form:

~/mmnet> pdf2dsc mmnet_canterbury.pdf
Error: /syntaxerror in readxref
Operand stack:

Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 \
%stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 \
%stopped_push 1 3 %oparray_pop 1 3 %oparray_pop 1 3 %oparray_pop 1 3 \
%oparray_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 \
%stopped_push --nostringval-- --nostringval-- --nostringval-- --nostringval-- \
--nostringval-- --nostringval--
Dictionary stack:
--dict:1052/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)-- --dict:100/127(ro)(G)-- \
--dict:230/230(ro)(G)-- --dict:14/15(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 2349
GPL Ghostscript 8.01: Unrecoverable error, exit code 1(newlines added to flags to make page readable)

Now that I've re-installed, however, gv seems more willing to open more PDF's. This is good, if all a little strange. If anyone has any ideas why a handful of PDF's might not be openable, while others are, I'd be happy to hear them... :)

JohnT
07-24-2004, 12:49 PM
I've run into that myself and belive it has more to do with the Adobe "version" of Acrobat that your trying to convert, than it does gs.

Stween
07-24-2004, 08:44 PM
Originally posted by JohnT
I've run into that myself and belive it has more to do with the Adobe "version" of Acrobat that your trying to convert, than it does gs. That's what I figure, but I still find it strange that Debian, by default for me, was not opening any PDF's, and only after removing and reinstalling the packages required for gv did it open more... :)

JohnT
07-24-2004, 10:44 PM
Originally posted by Stween
That's what I figure, but I still find it strange that Debian, by default for me, was not opening any PDF's, and only after removing and reinstalling the packages required for gv did it open more... :) Why would you find any behavior from any software strange? http://www.geocities.com/jtarin47/images/21.gif