I am trying to generate a pdf from a latex-generated ps document. (Note: I can not use pdflatex because of pstricks.)

In the tex file I load

    pdfborder=0 0 0]{hyperref}

After running latex I generate the ps file with dvips -Ppdf -GO input.dvi and my gs command is:

gs -dPDFX -dBATCH -dNOPAUSE -dPDFSETTINGS=/screen -sDEVICE=pdfwrite \
   -sPAPERSIZE=a4 -sOutputFile=output.pdf input.ps

After running that command output.pdf contains the first three pages. The error output is:

GPL Ghostscript 9.01 (2011-02-07)
Copyright (C) 2010 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Error: /rangecheck in --pdfmark--
Operand stack:
   --nostringval--   Subtype   Link   Dest   chapter.1   H   I   Border   --nostringval--   Color   --nostringval--   Rect   --nostringval--   ANN
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1910   1   3   %oparray_pop   1909   1   3   %oparray_pop   1893   1   3   %oparray_pop   1787   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   1917   14   5   %oparray_pop   --nostringval--
Dictionary stack:
   --dict:1160/1684(ro)(G)--   --dict:0/20(G)--   --dict:87/200(L)--   --dict:196/300(L)--   --dict:36/200(L)--
Current allocation mode is local
Last OS error: 2
Current file position is 758023
GPL Ghostscript 9.01: Unrecoverable error, exit code 1
GPL Ghostscript 9.01: ERROR: A pdfmark destination page 4 points beyond the last page 3.

Does anybody know this error and could help me please?

EDIT: I found out that it always breaks at the page before the first \footnote{} or \tableofcontents. So the produced PDF contains all pages before the first occur of those objects and the links to all chapters as pdfmarks, displayed in the sidebar. So I guess those in-document links cause the error. Any ideas?

  • This may be a dumb comment from not understanding the question, but i've always used ps2pdf to convert LaTeX-generated .ps (which I use on Linux) to .pdf (which I use on Windows), and never had an issue.
    – strmqm
    Commented Jul 29, 2011 at 10:06
  • Thank you, strmqm, but ps2pdf is also just calling ghostscript and thus produces the same error...
    – Simon
    Commented Jul 29, 2011 at 10:16
  • You should be able to compile code with pstricks directly to a PDF file using xelatex.
    – Caramdir
    Commented Jul 29, 2011 at 16:28
  • I could compiled using XeLateX. There was no Ghostscript 9.04 complains anymore!!!
    – user13431
    Commented Apr 9, 2012 at 22:15

3 Answers 3


The job contains a pdfmark which tried to make a link or bookmark beyond the end of the file (ie it references pages beyond the last page).

I believe this no longer generates an error in the latest version of Ghostscript (9.02) but can't check without seeing your file. Version 9.04 is due for release within days, you mighty like to wait and try that.

  • Thats what I also understood. The point is, that my document has over 40 pages, so page 4 should be in range. Looks as if it is checking for valid destinations before finishing all pages..?!
    – Simon
    Commented Jul 30, 2011 at 13:18
  • That shouldn't be the case, and we do have test cases that exercise this, but as I said, without seeing the PostScript, I can't really tell what's going on. You can always raise this as a bug on the Ghostscript bug tracker at bugs.ghostscript.com there's an opportunity to attach a specimen file there.
    – KenS
    Commented Jul 31, 2011 at 9:22
  • Thanks Ken. But that would mean that I had to reproduce the error on a second document as I am not allowed to share the informations in that document to anyone.
    – Simon
    Commented Aug 19, 2011 at 7:47

The problem seems to be solved by adding the option hypertexnames=false to the hyperref call.

Got it from http://www.pa.op.dlr.de/~PatrickJoeckel/pdflatex/index.html

Thanks you all for your hints!


I solved the problem with deleting the output *.ps file and then rerunning LaTeX.

Doesn't solve the source of the problem but is very quickly and easily done... :)

  • I delete the old ps-file every time before running latex. But what does it help?
    – Simon
    Commented Aug 19, 2011 at 9:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .