title: Ghostscript 9.07: Error: A pdfmark destimation ... points beyond the last page
body: <p>I use <code>gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -dFirstPage=$2 -dLastPage=$3 -sOUTPUTFILE=$4 $1</code> in a script to extract pages from a pdf file with Ghostscript 9.07. I obtain a lot of warnings (as in the first row in the following output) and one error: </p>
  
  <pre><code>GPL Ghostscript 9.07:    **** Warning: Outline has invalid link that was discarded.    
  GPL Ghostscript 9.07: ERROR: A pdfmark destination page 4 points beyond the last page 3.
  </code></pre>
  
  <p>The resulting pdf (consisting of the extracted pages) is fine, however. I am wondering why I obtain this error and the warnings although I chose the option <code>-q</code> for <code>quiet</code>. I did some search on that and found, for example, <a href="https://tex.stackexchange.com/questions/24428/latex-and-pdf-rangecheck-error-in-pdfmark-using-ghostscript">this</a>, but the pdf file is already generated with <code>hypertexnames=false</code> and so the suggested solution there does not work in my case (Ubuntu 13.04).</p>
  
  <p>Just to add: The .pdf file is generated via pdflatex from:</p>
  
  <pre><code>\documentclass{scrartcl}
  
  \usepackage[T1]{fontenc}
  \usepackage[american]{babel}
  \usepackage{tikz}
  \usepackage{hyperref}
  
  \begin{document}
  \tikz[remember picture, overlay]\node at (current page.south)[rectangle, fill, color=gray]{};
  \clearpage 
  \section{foo}
  \clearpage
  \tableofcontents
  \clearpage
  \section{bar}
  foo bar 
  \end{document}
  </code></pre>