title: How can I "manually" edit an annotation in a pdf without corrupting the file?
body: <p>I need to insert an hyperlink into a few thousand existing pdfs. I'm working with zend_pdf which apparently is not able to set an invisible border. The only way I found to make the link borders invisible (found it somewhere else on this site, <a href="https://stackoverflow.com/questions/1186955/zend-pdf-add-text-link-to-pdf-pag">here, to be precise</a>) is to search for each link "element" of the pdf and add a /Border annotation, like this:  </p>
  
  <blockquote>
    <p>echo str_replace('/Annot /Subtype /Link', '/Annot /Subtype /Link /Border[0 0 0]', $pdf->render());  </p>
  </blockquote>
  
  <p>Since I need to work on files that reside on my filesystem, I'm using the sed command for the search &amp; replace operation.<br>
  Now, at first sight this works, as the documents are displayed correctly by Acrobat 8, osx 10.6's Viewer and Ubuntu's document viewer. However, tools such as pdftk (1.41) and pdfinfo (0.12.1) report the structure is corrupted. This is annoying since it means that no further manipulation of the pdf using pdftk will be possible, since the tool refuses to work on the file as there are errors in it.
  I looked into the files using a binary editor and I found out that if I add more than two bytes after "/Link", the file gets corrupted. This confuses me a lot, since based on the pdf specifications (I'm using 1.4) there is no checksum except for streams, which should mean that one can add as much bytes as he wants, as long as he's not doing that inside a stream and the inserted bytes are valid pdf syntax.
  What am I missing here?</p>
  
  <p>Here is an example:<br>
  <a href="https://rapidshare.com/files/523780303/source.pdf" rel="nofollow noreferrer">the original pdf</a><br>
  <a href="https://rapidshare.com/files/645786889/processed.pdf" rel="nofollow noreferrer">the processed pdf</a></p>