TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

migrated from stackoverflow.com Jul 29 '11 at 16:10

This question came from our site for professional and enthusiast programmers.

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 Jul 29 '11 at 10:06
Thank you, strmqm, but ps2pdf is also just calling ghostscript and thus produces the same error... – Simon Jul 29 '11 at 10:16
You should be able to compile code with pstricks directly to a PDF file using xelatex. – Caramdir Jul 29 '11 at 16:28
I could compiled using XeLateX. There was no Ghostscript 9.04 complains anymore!!! – user13431 Apr 9 '12 at 22:15

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.

share|improve this answer
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 Jul 30 '11 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 Jul 31 '11 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 Aug 19 '11 at 7:47
up vote 4 down vote accepted

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!

share|improve this answer
This did not help for me, so I opened a new question: stackoverflow.com/questions/16252370/… – Marius Hofert Apr 27 '13 at 12:59

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... :)

share|improve this answer
I delete the old ps-file every time before running latex. But what does it help? – Simon Aug 19 '11 at 9:50

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.