Link to home
Start Free TrialLog in
Avatar of Chriseybaby
Chriseybaby

asked on

Printing pdf from javascript

Hi, is it possible to print a pdf from javascript?

I looked into using the window.open() method which opens the pdf but how can I call a print method on the child window?
Avatar of pzepernick
pzepernick

Maybe this thread will help:

https://www.experts-exchange.com/questions/20846776/Print-PDF-HTML-page-by-hidden-frame-or-no-window-at-all.html

I think you can reference the open window like so:

var mywin = window.open(...);

mywin.document.afunction()


Paul
Avatar of Michel Plungjan
You cannot.

However you can have a javascript instruction in the PDF that will make it print itself

2 0 obj
<</S /JavaScript
/JS (this.print(true))>>
endobj


Michel
Avatar of Chriseybaby

ASKER

Sorry i dont have much experience with pdf's, how do you put js in a pdf?
You do that when you create it.
If you do not create the pdf, I cannot help you. Sorry.
ASKER CERTIFIED SOLUTION
Avatar of rama_krishna580
rama_krishna580
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial