You need an annotation.

Paulo

> -----Original Message-----
> From: Whitney, Adam [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, October 08, 2008 1:22 AM
> To: [email protected]
> Subject: [iText-questions] Adding an action to an existing PDF
>
> Hi,
>
> I'm trying to read in an existing PDF and add an action to it, but I
> can't seem to figure out how to make the action work.
>
> I've tried adding the action to the over content, or the
> under content -
> but no luck.
>
> I've tried adding an action to an embedded file (the kind of action I
> really need) or an action to an URL (just to see if that
> could work) and
> still no luck.
>
> I've even tried upgrading from iText 2.0.8 to 2.1.3 and still no luck.
>
> I don't get any kind of cursor change (like to a hand) and nothing
> happens when I click inside the rectangle that I drew to make
> it easier
> to find the action area.
>
> Any help is much appreciated.
>
> Here's my code:
>
>
>     public void testAction() throws Exception
>     {
>         // prepare the output document with the cover sheet
>         Document pdfDoc = new Document();
>         PdfCopy writer = new PdfCopy(pdfDoc, new
> FileOutputStream("content/pdf/actionTest_out.pdf"));
>
>         pdfDoc.open();
>
>         // Set the coversheet in the output document
>         PdfReader reader = new
> PdfReader("content/pdf/coversheet.pdf");
>         int pageCount = reader.getNumberOfPages();
>
>         for (int pageNumber = 1; pageNumber <= pageCount;
> pageNumber++)
>         {
>             PdfImportedPage page = writer.getImportedPage(reader,
> pageNumber);
>
>             // Add a link on the first page of the coversheet
>             if (pageNumber == 1)
>             {
>                 PdfCopy.PageStamp ps = writer.createPageStamp(page);
>                 PdfContentByte content = ps.getOverContent();
>                 PdfAction action = new
> PdfAction("http://www.lowagie.com";);
>                 Rectangle rect = new Rectangle(210, 310, 320, 330);
>
>                 // Draw a rectangle around the action so we
> can find it
> easier
>                 rect.setBorderColor(Color.black);
>                 rect.setBorderWidth(1);
>                 rect.setBorder(Rectangle.BOX);
>                 content.rectangle(rect);
>                 content.setAction(action, rect.getLeft(),
> rect.getBottom(), rect.getRight(), rect.getTop());
>                 ps.alterContents();
>             }
>
>             writer.addPage(page);
>         }
>
>         pdfDoc.close();
>     }


Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter 
informação confidencial ou legalmente protegida. A incorrecta transmissão desta 
mensagem não significa a perca de confidencialidade. Se esta mensagem for 
recebida por engano, por favor envie-a de volta para o remetente e apague-a do 
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de 
usar, revelar ou distribuir qualquer parte desta mensagem. 

Disclaimer:
This message is destined exclusively to the intended receiver. It may contain 
confidential or legally protected information. The incorrect transmission of 
this message does not mean the loss of its confidentiality. If this message is 
received by mistake, please send it back to the sender and delete it from your 
system immediately. It is forbidden to any person who is not the intended 
receiver to use, distribute or copy any part of this message.


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to