Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

PDF: Save text (group description + text display questions) from survey as PDF?

  • Sweden
  • Sweden's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
6 years 8 months ago - 6 years 8 months ago #157319 by Sweden
There are apparently lots of ways to convert html pages to PDF (mpdf, fpdf, html2pdf, wkhtmltopdf, jsPDF etc. etc.), but no one really descripes how to convert e.g. a generated page from LimeSurvey into a PDF file (at least not in details). Haven't really tried too many options because I simply don't know where to start and where to insert code etc.

User should be able to save/download what is seen on screen as PDF file (must work with the most common browsers on PC, iOS, Android devices etc.) What is the most simple way? I don't need a lot of choices - I don't care if pagebreaks, page size, margins etc. are a little bit off. Don't need or want to store the PDF result on server and I don't need a solution that can email the PDF file. Also don't need header and footer (although it would be nice).

In my survey (not public yet), equations control what is seen on the screen (a combination of Group Description and Text Display Questions) - this combined text is shown before the end page and it would be nice to have a "Save as PDF" button on that page. Browsers "print as PDF" option isn't a good option (hyperlinks in text don't work etc. - each browser has its problems).

Have used so much time searching for a solution on/off through the years, but have never found a way to do this. I really hope someone can help!? Based on the amount of similar posts in this forum, it seems like many people request a good way to save survey text (only what is shown on the screen) as PDF.
Last edit: 6 years 8 months ago by Sweden.
The topic has been locked.
More
5 years 3 months ago - 5 years 3 months ago #179172 by haule1976
Please give us an advice for this!
Thank you so much for your help!
Last edit: 5 years 3 months ago by haule1976.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 3 months ago #179176 by DenisChenu

Sweden wrote: … Don't need or want to store the PDF result on server and I don't need a solution that can email the PDF file. Also don't need header and footer (although it would be nice).…

Browsers "print as PDF" option isn't a good option (hyperlinks in text don't work etc. - each browser has its problems).

In my opinion :
If you want to be like "What you see is what you print" browser print is the best solution.

If you want to have same print for all browser : then you need to construct the PDF yourself using PHP and a pdf library.

And yes : PHP developer is a real work, a real job …⋅

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
5 years 3 months ago #179181 by Mazi
We had to deal with such requirements at many of our projects and form our experience using a PDF library can not only cause lots of trouble but is also very complex to implement.
For that reasons, we usually add a "Print overview" button to our summary pages. That button uses some JavaScript to call the browser's print feature. Most modern browsers nowadays support printing to PDF directly.

Note that optimizing the print CSS for proper print output for different browsers can be quite a pain but is still easier than using a PDF library and doing lots of PHP coding for generating the PDF which often also doesn't look well.

If you need help with your project feel free to drop us a note.

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.
More
5 years 3 months ago #179185 by haule1976
Dear Mazi,
Could you please help me to guide some steps ?
How can build "Print overview" button and print out pdf directly with CSS ?
Where do we need to insert css code into ?
...
Many thanks for your help!
Best regards.
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
5 years 3 months ago #179191 by Mazi
Use HTML at the question or end text to create a proper button: www.w3schools.com/tags/tag_button.asp

Then add some JS to call the print feature if the button gets clicked: www.thoughtco.com/how-to-add-a-print-button-4072006

Later you can edit the custom.css file to add special print css to optimize the formatting of the printed output (this can be tricky).: benfrain.com/create-print-styles-using-css3-media-queries/

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The following user(s) said Thank You: haule1976
The topic has been locked.
More
5 years 3 months ago #179225 by haule1976
Thank you so much Mazi!
Kind regards.
The topic has been locked.
More
5 years 3 months ago - 5 years 3 months ago #179337 by haule1976
Dear Mazi,
I am newbie but I tried to do as your guide and I got good results with item 1 & 2.
item 1: Use HTML at the question or end text to create a proper button
item 2: Add some JS to call the print feature if the button gets clicked
Now, I am stranded with item 3: Edit the custom.css file to add special print css to optimize the formatting of the printed output...
Could you please help me to explain this item.
Many thanks for your guidance!
Best regards.
Last edit: 5 years 3 months ago by haule1976.
The topic has been locked.
  • Mazi
  • Mazi's Avatar
  • Offline
  • Official LimeSurvey Partner
  • Official LimeSurvey Partner
More
5 years 3 months ago #179339 by Mazi
Hmm, I can't really explain the CSS adjustments, it depends on what you want to see at the printout. For example, we usually hide the header and footer and sometimes some further elements of the to be printed page. Often you also want to define how page breaks at the printout should be done. All this can be done at the custom.css using media queries for printing.
Note that CSS is a complex topic and for such special things you may need some experience or read and learn a lot. Alternatively, just contact us if you need a little paid support to fix certain details at the printout.

Best regards/Beste Grüße,
Dr. Marcel Minke
Need Help? We offer professional Limesurvey support: survey-consulting.com
Contact: marcel.minke(at)survey-consulting.com
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose