Printing User Input to a PDF

Aug 31, 2017

Greetings - 

I've seen multiple threads on this, tried one (it did not work). 

Anyone know if I can allow the user to print their text input?

So, I have an activity with a number of text input areas. At the end I would like to provide a print results button that, when clicked, will take all of the user inputs (held in a number of variables), open a new window and dispay the user  text in a PDF. 

I have taken this JavaScript (from someone else's solution, which did not work for me) and put it on a button (execute JavaScript when clicked). I have also included two files that I was told to, a print.html, and a logo.png in the folder main output folder. 

I know little of JavaScript, any help is appreciated. 

JavaScript is:

var player = GetPlayer();
var header = "CL700 Mod 3 Free Online Research~~"
var args =(
"Question 1~~" +
player.GetVar("Q1") +
"~~Question 2~~" +
player.GetVar("Q2") +
"~~Question 3~~" +
player.GetVar("Q3")
)
var url = ("print.html?=" + header + args);
window.open(url,”_blank”,”width=800,height=600,menubar=no,scrollbars=yes”);

26 Replies
Glenn Jones

Hi Amy

I tried to figure this one out myself a while ago....best solution I could find required the end user having some specific piece of software installed at their end - so I gave up!

I've found this today which talks about saving variables to a text file which gets saved locally - no idea if it's of any use to you...

https://community.articulate.com/discussions/articulate-storyline/recording-user-s-name-and-email-address#73694 

Patty Brandt

Hi all, I am wondering if you could help me figure out a problem I am having with a Storyline 360 interaction. I created a "cover page" activity and when done, I want the users to print their cover page to a PDF, which I am able to do with the Print button function. No problem there whatsoever. However, when I tested printing to a PDF on my desktop yesterday, the PDF print out looked perfect, but today when I printed my cover page to a PDF from my laptop, the PDF is distorted.

Eveline Holmes

Hi all

I'm having a look at this type of interaction, just to see how it would work for me.  I'm investigating note screens for users to take notes throughout a course and print them out at the end. I am trying out lightboxes and layers.

I used your code Eric as a guide and it worked perfectly - thanks so much.  The only issue is that the X obscures the player in the lightbox, so that wouldn't be a runner for me.  

Text not wrapping on PDF from Layers

I've tried it again using layers instead of light boxes but the issue I'm having is that the text isn't wrapping in the pdf, so I'm not getting all my notes. 

I have Googled and searched through these boards for an answer but haven't found anything.  I've no formal experience with coding, just mess around with it when I have to, so any help would be greatly appreciated.

Include a variable in the code to customise the title of the notes page

Another thing I would like to do is to adjust the code so instead of having the same standard text appearing at the top, I can customise it to add the session title.  I won't want to do this for each course so thought of assigning a variable "CourseName" to a textbox with the title in a template. 

I've tried to manipulate the code in various ways but can't get it to work. Again, any help would be appreciated.

I've added my storyline file in case that help.

Thanks in advance!

 

 

Emily Knox-Clifton

Hi All, 

I've tried using Eric's template and got it to work, however now that I have added in more text entries the PRINT button doesn't work. 

Is anyone able to look at the code for me, to see if I'm missing anything. Been trying to figure out why it's not working for the last hour or so.

kathryn brown

Hi Nedim,

Thank you for this code to print using JavaScript! It has the formatting I needed. I am hoping someone can help me with the printing issue though. The Print dialog box doesn't open automatically and the html file that holds the contents just keeps loading it seems as the top left corner has the neverending loading circle spinning. See attachment. I've also included a screenshot of the code. I've been at this for a few hours and am clueless as to why this isn't working.

Thank you in advance for your help!

Nedim Ramic

Your code is fine as far as I can see on the screenshot (Step 3). Could be something else, maybe browser or device specific. Have you tried to run your project in different browsers? What device you are using to run your project? If you are willing to share your story file I'd be more than glad to test it out for you more in detail. 

kathryn brown

Hi Nedim,

Thank you so much for your quick response. I am attaching my Storyline file. Thank you for taking the time to check it out! I cut out the content to protect client content. You can access the notes via the navigation at the top of the player and the JavaScript is on slide 2.2. 

Best,

Kathy

kathryn brown

Hi Nedim!

Thank you so much for looking at and modifying the code! I so appreciate you taking your time to do that. It's what I love about the Articulate community - jump in and help for the greater good. Did you by chance publish it, and if so, did it work for you? I'm diving back in and going to check things out now, and crossing fingers it works!

Best,

Kathy