cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Open Print Dialog using JavaScript

AlexGiguere
Contributor
0 Likes
865

Hi folks, I'm trying to open dynamically the print dialog window for printing the PDF (Ctrl + P) in WebDynpro ABAP using JavaScript.

The JavaScript seems to be executed only for Interactive Forms, however I don't need to use interactive but only Print-Based Forms.

This line of code works if I assign it to an event like click for a button, I tried to call it in the doc:ready event but it does not work

xfa.host.print(1, "0", "0", 0, 1, 0, 0, 0);

Please I need some help and I hope it's possible!

Alex

View Entire Topic
Former Member
0 Likes

Hi,

Try this code


//xfa.host.print(1, "0", (xfa.host.numPages -1).toString(), 0, 1, 0, 0, 0);
xfa.host.print(0,"0","0", 0, 1, 0, 0, 1);
xfa.host.exportData("",1);

Kind Regards,

Mukesh

AlexGiguere
Contributor
0 Likes

Thanks, we are getting close!

This line of code works, but it does not prompt me with the print dialog box (because of the first parameter is 0)

xfa.host.print(0,"0","0", 0, 1, 0, 0, 1);

I got this message box "This document is trying to print. Do you want to allow this?" Yes/No....

Ok, that works but I would like to have the standard print dialog window instead, where you could select your printers.

This line of code prompt me to save the XDP, this is not what I want

xfa.host.exportData("",1);

In which event should I place the script??

Also, script only seems to be executed for interactive forms, I don't want to generate interactive forms, they are more heavy to render, this is only for print based forms!

thanks

Alexandre Giguere

Former Member
0 Likes

Hi,

It is currently not possible to trigger printing the PDF from ouside the PDF (e.g. in WD).

And for all of you trying to figure out how to print using the print dialog via scripting (use it for example in a click event button):

event.target.print()

This is Acrobat Java Script working only in interactive PDF forms.

Regards,

Juergen

AlexGiguere
Contributor
0 Likes

Hi Mr. Hauser, I remember I had asked you this question at TechEd Phoenix, you were'nt sure if it was possible!

Thanks for the feedback and I really appreciate your book!

We found a way of doing that, this is not very state-of-the-art, but it works!

AlexGiguere
Contributor
0 Likes

Prerequisite is that the focus is to be placed on a WebDynpro UI element and not the Interactive Form UI.

We are using WD4A as standalone application, it's not integrated with NW Portal or NW BC. The WD4A is encapsulated into a frameset in an html page, we could add another frameset (invisible) that will search the PDF object and print it (in JavaScript)

AlexGiguere
Contributor
0 Likes

For an unknow reason, I'm not able to post the JavaScript code, I got an HTTP 501/505 errors, anyway, if you would like to have the code, write me an email! Check in my business card, it seems we can't include email address in our post!