I'm using iText-5.0.1 library - ‘PdfAction’ Class which defines an action that can be triggered from a PDF file.
Currently, I am using PdfAction gotoLocalPage() method and successfully able to Create a GoTo action to an internal page of PDF using following code.
PdfAction action = PdfAction.gotoLocalPage(link.getPhysicalvalue(), d, stamper.getWriter());
over.setAction(action, llx,lly,urx,ury);
stamper.close();
Now, I'm trying to add a icon containing link (referenced by a audio or video URL) in PDF to launch an external resources like audio , video etc. using iText.
I tried below code for the same but unable to add a link in PDF to launch an external resources.
Rectangle linkLocation = new Rectangle(x, y, x + w, y + h);
PdfDestination destination = new PdfDestination(PdfDestination.FIT);
PdfAnnotation link = PdfAnnotation.createLink(stamper.getWriter(),
linkLocation, PdfAnnotation.HIGHLIGHT_INVERT,
new PdfAction("http://www.google.com")
);
link.setBorder(new PdfBorderArray(0, 0, 0));
stamper.addAnnotation(link, 1);
stamper.close();
Can anyone please guide how to create/add a link to launch external resources like any mp3, image, video URL, etc. Thanks.