You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by mohammed althaf <al...@gmail.com> on 2014/11/18 10:43:32 UTC

Adding Javascript using PDActionJavaScript

Hi All,

I am using PDActionJavaScript to insert JS to the PDF.

Scenario:
I have added the this.print to auto print the pdf as soon as the file is
opened.It opens the print dialog as soon as the file is opened in new
window.

Issue i am facing is ,I need to close the pdf browser window when the user
clicks  prints/cancel in the print dialog.

I am not able to handle it in my JS as i lose control over it as soon as
the print dialog is opened .

Can you please let me know a solution /pointers to handle this.

Thanks,
Althaf

Re: Adding Javascript using PDActionJavaScript

Posted by John Hewson <jo...@jahewson.com>.
Hi Althaf,

JavaScript in your PDF can’t be used to control the browser window, only the
PDF viewer. Plus it won’t work in browsers which ship with their own PDF
viewers which don’t support JavaScript in PDFs, such as Chrome and Firefox.

Because you’ve opened the new window using JavaScript in the browser, you
should also be able to close it, perhaps calling window.close() after some
quantity of time has passed would work? I imagine that the closing of the
window will be blocked while the print dialog is displayed.

-- John

> On 18 Nov 2014, at 01:43, mohammed althaf <al...@gmail.com> wrote:
> 
> Hi All,
> 
> I am using PDActionJavaScript to insert JS to the PDF.
> 
> Scenario:
> I have added the this.print to auto print the pdf as soon as the file is
> opened.It opens the print dialog as soon as the file is opened in new
> window.
> 
> Issue i am facing is ,I need to close the pdf browser window when the user
> clicks  prints/cancel in the print dialog.
> 
> I am not able to handle it in my JS as i lose control over it as soon as
> the print dialog is opened .
> 
> Can you please let me know a solution /pointers to handle this.
> 
> Thanks,
> Althaf