Results 1 to 5 of 5

Thread: Zend_Pdf_Annotation_Link borders

  1. #1
    Sparrowhawk is offline Junior Member
    Join Date
    Nov 2010
    Posts
    7

    Default Zend_Pdf_Annotation_Link borders

    Hi,

    Does anyone know whether it is possible to change the colour of the border that is placed around annotations when creating them, eg through the use of Zend_Pdf_Annotation_Link?

    At present, all the links I have generated have a black border around them. I'd like to set them to the same colour as the background to make them disappear.

    I cannot find a solution online so was hoping that somebody on this forum had come across this before and has a solution.

    Many thanks

  2. #2
    Sparrowhawk is offline Junior Member
    Join Date
    Nov 2010
    Posts
    7

    Default

    I've managed to do a hack to solve this, although of course it's far from ideal.

    having saved the file to a file specified in $savePath, I do the following (I'll be adding error trapping too of course later on):

    Code:
            
            // Due to Zend_Pdf always forcing a black border around annotations, we run the following shell command
            // to replace the links with links with no border
            // we need to supply an extension to -i otherwise it might fail with "-i may not be used with stdin" error on some platforms
            // so this will create a backup but then we can just delete it.
            $cmd = 'sed -i ".bak" "s|/Annot /Subtype /Link|/Annot /Subtype /Link /Border[0 0 0]|g" ' . $savePath;
            shell_exec($cmd);
            unlink($savePath . '.bak');
    Hope this helps anyone else in the same predicament.

  3. #3
    Sparrowhawk is offline Junior Member
    Join Date
    Nov 2010
    Posts
    7

    Default

    Update - not working on our server

    Back to the investigation!

  4. #4
    Sparrowhawk is offline Junior Member
    Join Date
    Nov 2010
    Posts
    7

    Default

    Well don't I look the fool now? I was so focused on sorting it out via the shell that I overlooked simple PHP:

    Code:
            // Do the post-processing in PHP rather than using the shell. Doh!
            $tmp = file_get_contents($savePath);
            $tmp = str_replace("/Annot /Subtype /Link", "/Annot /Subtype /Link /Border[0 0 0]", $tmp);
            file_put_contents($savePath, $tmp);

  5. #5
    nerkn is offline Junior Member
    Join Date
    Aug 2013
    Posts
    1

    Default dynamic generation

    Very thank you for solution, I think I've spent 4hours trying to disable black borders.
    I tried creating a white box, and many other techniques, all failed to work.

    Since I'm generating on the fly pdfs, I used this.

    Code:
    			$this->getResponse()->setHeader('Content-type', 'application/x-pdf', true);
    			$this->getResponse()->setHeader('Content-disposition', 'inline; filename=filetrace.pdf', true);
    			$this->getResponse()->setBody(str_replace("/Annot /Subtype /Link", "/Annot /Subtype /Link /Border[0 0 0]", $pdf->render()));
    [/QUOTE]

    I think zend should die

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •