Hi, I want to use the HEScript function PrintPDF
, but it generates PDF of the whole webpage.
exeoutput.RunHEScriptCode(‘PrintPDF’);
I want to use it to generate PDF of a specific iFrame
on my webpage.
Basically, I am developing an application that has some settings on the left side and as the user changes them, the content in the right side iframe changes accordingly.
And finally the user can click “Save” and the script should generate PDF from only the iframe contents.
I tried running it from the iframe window like this:
document.getElementById(’#myiframe’).contentWindow.exeoutput.RunHEScriptCode(‘PrintPDF’);
But it still prints the whole page. I want contents from just the frame.
I also tried opening a new popup window:
var mywin = window.open(“https://heserver/files/preview.php”);
mywin.exeoutput.RunHEScriptCode(‘PrintPDF’);
But is still prints the content from the main window, and not from the popup.
Also, I tried using standard print
function:
mywin.print();
This prints the contents from only target window as expected, but it has some issues:
- It opens the "Select a printer" dialog, and then the "Save file" dialog.
- I want to show only the Save file dialog, because I always generate PDF.
- Moreover, when I select "Microsoft Print To PDF" as printer, the text in generated PDF is not select-able.
- It is like I have generated the PDF from an image or something - the mouse pointer always shows the arrow and not the “
I
” as we see in the select-able text.
The PDF generated by HEScript’s PrintPDF
works great for this - it correctly shows text as text, and I can select the text from PDF as expected.
I would really like to use HEScript PrintPDF
function to generate PDF from a specified window.
Also I would avoid using external libraries such as fpdf
etc., because my preview page has very complex HTML/CSS design that would be very difficult to use in external libraries.
Please help me on this as quickly as possible. Thanks.