Print button - javascript

Sep 14, 2012

Hi, I would like to add a button that would allow the user to print the page. It seems like the easiest way would be to add a trigger to a button to execute javascript.  Unfortunately, I know nothing of javascript.  Can someone help me out with what need to goes into that script box?

Thank you!!

69 Replies
Ivana Pavcic

Hello there,

I was wondering if anyone in the community could help me.. I have used the javascript desribed in this post to print a certificate that will be unfortuntely printed out with the player. I would like to include a line in the javascript that says "remove the print button before printing". Condering that I know aboslutely nothing regarding java, and my google searches have turned up nothing, does anyone know the actual programming language I can include with the window.print(); command that will do this?

Thanks,

Ivana

Phil Mayor

Ivana Pavcic said:

Hello there,

I was wondering if anyone in the community could help me.. I have used the javascript desribed in this post to print a certificate that will be unfortuntely printed out with the player. I would like to include a line in the javascript that says "remove the print button before printing". Condering that I know aboslutely nothing regarding java, and my google searches have turned up nothing, does anyone know the actual programming language I can include with the window.print(); command that will do this?

Thanks,

Ivana


As Steve says just add a trigger to hide th print button, ensure the trigger is above the javascript trigger

Jill McNair

Anyone know of a way to allow learners to print a multipage document?  My client wants learners to be able to print a six page document (a job aid).  It is a PDF.  I thought perhaps learners could just download the PDF, then prinit it themselves, but the client says that their LMS will not permit that.  Seems unusual to me.  Any suggestions would be appreciated.

Steve Flowers

Hi Jill,

Here's something that might work for you:

http://www.pdfobject.com/

This requires some custom HTML magic but will offer you flexibility to display the PDF in a Web Object. If the server isn't able to serve up PDF's this won't help. The file must be downloaded to the client to print. You could try to convert the PDF to SWF and embed on the page. Many converters will make a single swf. Some have trouble printing individual pages. The old Flashpaper from Macromedia used to handle conversion.

Artur Trzebunia

I believe the reason why Chrome and Firefox sometimes display a blank HTML page when invoking the window.print() function is because Storyline runs your project as a flash object on the PC/Mac.  When you right click on the Flash object you can click "Print" to print that slide.  So, is there a javascript command that will invoke the Print function from the Flash object's menu?

Nancy Woinoski

Mark Blessington said:

I published a test file using the print screen java script. I tried to print a page from the player. Nothing happened. I think this is because Mac does not recognize the java script: window.print();


Hi Mark - were you testing locally or from a web server or LMS?  Some browsers block JavaScript when run locally.  

Deniz Olcay

I'm also getting the issue with Firefox and Chrome printing a blank page. Tried on web, doesnt work.

Works in IE, but is anyone else getting the printed window cut off on the right? Is there a way to resize the window that prints?

If there are any updates on how to make sure the slide prints in IE/Chrome/Firefox that would be great too...

BJ Kamler

Doug Bedinger said:

I too want to print only the slide.  I tried the javascript option, and it works, but I'm getting 2 pages, not just the one with the print button.  Thoughts?

I am having the same issue as Doug and I didn't see any replies or answers to this issue.  I'm using the javascript window.print() and it works but prints two pages instead of one... the second page is blank except for headers and footers. We will have hundreds of people printing these certificates... I don't want to kill anymore trees than I have to. Our users are not computer savvy, so I'm afraid giving them directions to print the current page or print to file would go unheeded. Ideas, anyone?

HPL Training

Artur Trzebunia said:

I believe the reason why Chrome and Firefox sometimes display a blank HTML page when invoking the window.print() function is because Storyline runs your project as a flash object on the PC/Mac.  When you right click on the Flash object you can click "Print" to print that slide.  So, is there a javascript command that will invoke the Print function from the Flash object's menu?


I am also using Chrome and looking for the option to print from the Flash menu using a button/command. Any suggestions? 

Rose Kent

I've been reading through these past posts as I'm also having trouble printing my results page. I'm wondering if I have a more basic issue. I've added the print results button through the Results slide options. When I click the button, a IE window opens with the title of "Results", but the screen is blank. I'm guessing maybe an IE setting needs tweaked? Using IE 9.

Jorge Lugo

Phil Mayor, 

I used triggers for that

Object Button Print:

1 Change state of buttom to hidden when user clic on Button Print 

2 Ejecute javascrip when user clic on Button Print

Object: Hotspot 1

1 Change state of buttom Print to normal when mouse hover over.

I add a example:

But the problem is when i print the page, is blank but im working on it.

TIMOTHY KUHN

window.print() javascript is nice......however for my purposes I came up with the below and it seems to work nicely (in all browsers)

Modify a Quiz Results slide.

The process to do this is basically:

 

1.       Have a project with result slide……drag the results off of slide so user doesnt see them, however depending on your purpose you could keep them on the slide

2.       Change the result slide properties to include print results btn

3.       Rename/label print result btn to print handouts or whatever approp.

4.       Save and publish……..not do not zip yet

5.       Go to the published files…….find the story_content folder………..locate report.html in that folder………use html editor (or notepad) delete all the html in file and design it to be the document you want the user to print.  Or better yet create basically an html webpage that may have links to multiple handouts, etc.  Just make sure the documents that you are linking to are located within the story_content folder so to ensure that they get loaded into the lms.

6. zip the files

7. upload to lms

 

The process is pretty easy……..biggest thing is you must save project, publish, modify the report.html file, then zip it for the upload………..so basically same process except you have a delay between publish and zip……….to permit access to modify the report.html file.  I haven't found a way to prevent the user from having to enter their name when they click the print button yet, however my hope is that maybe i can use this to track who access the material and likely printed it.

TIMOTHY KUHN

Another method would be to use insert web object, save and publish, (don't zip), add html page and link to documents, images in newly created folder.  Open story file link locally ot relative link (html file), save and republish with different name......copy and paste the html file out of first published and paste into the 2nd published files..........then zip and upload that to LMS..........now you have embed webpage with links to documents that is secure in SCORM, no risk of links breaking, etc.