JavaScript to generate pdf report at the end of survey | XM Community
Skip to main content

JavaScript to generate pdf report at the end of survey

  • November 4, 2022
  • 8 replies
  • 531 views

Forum|alt.badge.img+1

Hi there,
Im looking for Javascript to generate pdf report at the end of survey. This report contains all responses including graph, result and recommendation which created using Javascript too.


8 replies

Aanurag_QC
QPN Level 5 ●●●●●
Forum|alt.badge.img+31
  • November 4, 2022

Just to confirm, do you want a pdf to be downloaded for each participant every time they complete the survey?


Forum|alt.badge.img+1
  • Author
  • November 4, 2022

Aanurag_QC yes, correct.


Aanurag_QC
QPN Level 5 ●●●●●
Forum|alt.badge.img+31
  • November 4, 2022

As far as I can recall Qualtrics does not have the option to download a pdf at the end of the survey. You have the option to view the response but not download it. For the Graphs, you can either use Report or Dashboard to download such data and provide it to the participant.


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+46
  • November 4, 2022

imalik
2 ways to do this if you haven't already explored.

  • When you enable show response summary within the customize options of end of survey it enables a button to download PDF.

image.png
  • You can create a button that does the job if you want a specific div element to be printed. You can create a custom end of survey via using table include it in an id and everytime respondent clicks print that would be printed. I have kept it on button click you can do it on page load as well.




 


Hope it helps!


Forum|alt.badge.img+1
  • Author
  • November 4, 2022

Deepak Hi, thanks it works for the second option. However, the result generated only for the current page (where the download button located). Any other way to generate the whole response from the first page (beginning) to last page?


Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+46
  • November 4, 2022

imalik
Can you provide a visual of what your configuration is?


Forum|alt.badge.img+1
  • Author
  • November 4, 2022

Deepak
So this survey consists of several sections and each sections has several questions. Every time the next button is clicked, it will run the script as follows:
//(Section 1)
Qualtrics.SurveyEngine.addOnPageSubmit(function (type) {
let surveyHTML = document.createElement("div");
if (type == "next") {
let viewHTML = document.getElementById("Questions");

surveyHTML.append(viewHTML);

Qualtrics.SurveyEngine.setEmbeddedData( "Survey_HTML", surveyHTML);
}
});

//(Section 2)
Qualtrics.SurveyEngine.addOnPageSubmit(function (type) {
let currentViewHTML = Qualtrics.SurveyEngine.getEmbeddedData( "Survey_HTML"); //got empty object
let viewHTML = document.getElementById("Questions");

if (type == "next") {
currentViewHTML.append(viewHTML); //got error
Qualtrics.SurveyEngine.setEmbeddedData( "Survey_HTML", currentViewHTML );
}
});

And in the end of the survey (not tested yet):









Deepak
QPN Level 8 ●●●●●●●●
Forum|alt.badge.img+46
  • November 4, 2022

imalik
If you just show the entire response summary on end of survey and then print it will print the entire response.
Or you will have to pipe everything in one hidden question element and print that specific question
Hope it helps