0

I wrote some jQuery to create a survey that outputs a somewhat complex report. The report is a mix of scores grabbed from variables and also content that I have appended to HTML elements (using jQuery).

The report displays nicely on my website. Now, I want to allow users to download it to a PDF. I'm on a wordpress site, so I've tried just about every plugin out there that converts a page to PDF file, yet they always look terrible and never grab my jQuery variables or appended content.

Is there some sort of simple script I can write that also grabs the variables/appended content and adds it to a PDF or Email?

mickdeez
  • 507
  • 3
  • 7
  • 16

2 Answers2

0

There are several pdf generators using javascript.

usage is pretty straightforward.

Best of luck!

ThomasK
  • 300
  • 1
  • 8
0

I have pretty extensive experience using pdfmake like ThomasK mentioned and I will say that although it is very nice to use, pdf generation is always a pain. I have made hundreds of PDF reports with pdfMake and I have a good strategy.

The key is viewing your data like a large table using 2D arrays. Javascript makes working with arrays easy, so if you're comfortable with js you could just use the .push() method onto one large 2D array and then have a button that runs a function that creates docDefinition and then runs pdfMake.createPdf(docDefinition).open().

Treat each array within the array as a row, and each item within the sub array as a column.

Check out the pdfMake playground and their docs are pretty good too.

Colin Harrison
  • 184
  • 2
  • 18