You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Jana Sefcikova <js...@capso.com> on 2016/05/16 10:39:12 UTC

Re: How to add annotation that opens url in new tab/window ?

Hi Maruan, thank you very much for your answer. We went for fronted
solution for now.


On Tue, Apr 26, 2016 at 10:59 AM, Maruan Sahyoun <sa...@fileaffairs.de>
wrote:

> Hi,
>
> > Am 26.04.2016 um 11:12 schrieb Jana Sefcikova <js...@capso.com>:
> >
> > Hi Maruan,
> >
> > thank you for your response.
> >
> > Where this code can be placed ? Somewhere in GUI or it can be done
> > programatically ?
>
> I havnÄt had the time to test the code but that should work I think:
>
> you can add Javascript to an annotation like this for a given annotation
> 'annot'
>
> PDActionJavaScript javascriptAction = new
> PDActionJavaScript("app.launchURL("http://yoururl", true);");
> PDAnnotationAdditionalActions actions = new
> PDAnnotationAdditionalActions();
> actions.setU(javascriptAction);
> annot.setActions(actions);
>
> > What is app ?
>
> app is an Adobe Acrobat/Reader JavaScript object representing the
> application the PDF is running in (Acrobat/Reader). This is part of the
> Acrobat JavaScript SDK http://www.adobe.com/devnet/acrobat/javascript.html
>
> Let me know if you are experiencing any issues.
>
> BR
> Maruan
>
>
>
> >
> > Thank you
> >
> > ps: I am first time replying to this mailing list, and I am not sure
> > whether this answer will be correctly placed under original discussion,
> as
> > I don't know who should be recipient
> >
> >
> > On Sat, Apr 23, 2016 at 6:55 PM, Maruan Sahyoun <sa...@fileaffairs.de>
> > wrote:
> >
> >> Hi,
> >>
> >>> Am 23.04.2016 um 19:47 schrieb Tilman Hausherr <THausherr@t-online.de
> >:
> >>>
> >>> Hi,
> >>>
> >>> If you download this PDF
> >>>
> >>
> https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
> >>> open it, then go to the second page, and click on the link, what
> happens?
> >>>
> >>> (I suspect this is rather a problem of the browser or an Adobe Reader
> >> setting)
> >>>
> >>> Tilman
> >>>
> >>> Am 23.04.2016 um 13:27 schrieb Jana Sefcikova:
> >>>> Hi, I am using pdfbox to create links inside pdf as follows:
> >>>>
> >>>> PDAnnotationLink txtLink = new PDAnnotationLink();
> >>>>
> >>>> // code for setting position
> >>>>
> >>>> PDActionURI action = new PDActionURI();
> >>>>
> >>>> action.setURI("http://www.google.com");
> >>>>
> >>>> txtLink.setAction(action);
> >>
> >>
> >> a regular link annotation doesn't have the capability. What you can do
> is
> >> adding a JavaScript with the following content
> >>
> >> app.launchURL("http://yoururl", true);
> >>
> >> replacing <yoururl> with the actual one.
> >>
> >> Be aware that this JavaScript is application specific so might not work
> in
> >> Readers other than Adobe Reader / Acrobat.
> >>
> >> BR
> >> Maruan
> >>
> >>
> >>>>
> >>>> But when I open pdf in browser and click on the annotated text, it
> opens
> >>>> url in the current tab in the browser.
> >>>>
> >>>>
> >>>> Can I open links in new tab using pdfbox ? If yes, could you provide
> >> some
> >>>> example ?
> >>>>
> >>>> Thank you very much
> >>>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> >>> For additional commands, e-mail: users-help@pdfbox.apache.org
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> >> For additional commands, e-mail: users-help@pdfbox.apache.org
> >>
> >>
> > On Sat, Apr 23, 2016 at 6:55 PM, Maruan Sahyoun <sa...@fileaffairs.de>
> > wrote:
> >
> >> Hi,
> >>
> >>> Am 23.04.2016 um 19:47 schrieb Tilman Hausherr <THausherr@t-online.de
> >:
> >>>
> >>> Hi,
> >>>
> >>> If you download this PDF
> >>>
> >>
> https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
> >>> open it, then go to the second page, and click on the link, what
> happens?
> >>>
> >>> (I suspect this is rather a problem of the browser or an Adobe Reader
> >> setting)
> >>>
> >>> Tilman
> >>>
> >>> Am 23.04.2016 um 13:27 schrieb Jana Sefcikova:
> >>>> Hi, I am using pdfbox to create links inside pdf as follows:
> >>>>
> >>>> PDAnnotationLink txtLink = new PDAnnotationLink();
> >>>>
> >>>> // code for setting position
> >>>>
> >>>> PDActionURI action = new PDActionURI();
> >>>>
> >>>> action.setURI("http://www.google.com");
> >>>>
> >>>> txtLink.setAction(action);
> >>
> >>
> >> a regular link annotation doesn't have the capability. What you can do
> is
> >> adding a JavaScript with the following content
> >>
> >> app.launchURL("http://yoururl", true);
> >>
> >> replacing <yoururl> with the actual one.
> >>
> >> Be aware that this JavaScript is application specific so might not work
> in
> >> Readers other than Adobe Reader / Acrobat.
> >>
> >> BR
> >> Maruan
> >>
> >>
> >>>>
> >>>> But when I open pdf in browser and click on the annotated text, it
> opens
> >>>> url in the current tab in the browser.
> >>>>
> >>>>
> >>>> Can I open links in new tab using pdfbox ? If yes, could you provide
> >> some
> >>>> example ?
> >>>>
> >>>> Thank you very much
> >>>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> >>> For additional commands, e-mail: users-help@pdfbox.apache.org
> >>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> >> For additional commands, e-mail: users-help@pdfbox.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>