Create PDF with Table using Javascript
Asked Answered
G

4

5

I'm currently creating a phonegap app that lets you input Data and then creates a PDF with that data. The Input is done, but I can't find anything to make a PDF with Javascript. So far I only found jsPDF, but that doesn't support tables. The App must work offline. Does someone have an Idea?

Gerick answered 23/1, 2014 at 10:36 Comment(1)
You could probably use pdf.fromHTML() to create tables, but then you would have to generate a HTML table first.Equities
F
0

Bytescout PDF Generator SDK for Javascript might come in handy: http://bytescout.com/products/developer/pdfgeneratorsdkjs/index.html

Ensure that browser inconsistencies for your targeted devices are taken into account.

Fleece answered 23/1, 2014 at 11:1 Comment(0)
D
10

I wanted to use jsPDF to generate tables so I made a table plugin for it. Check it out! jspdf-autotable It has all the features I was looking for in a table plugin.

  • Auto width (100% of page width or only as much as required)
  • Multiple pages
  • Custom headers and footers
  • Multiple tables on the same page
  • Custom styling
  • Examples

enter image description here

Dragster answered 3/4, 2015 at 20:54 Comment(0)
E
4

pdfmake let's you easily create tables.

It can automatically repeat headers, supports column/row spans and comes with a lot of other options.

There's an example for tables in the playground

Enthrall answered 17/5, 2014 at 22:22 Comment(3)
Please indicate in your answers that you are the creator of pdfmake. Otherwise it looks like astroturfing.Budworth
No other js lib support nested tables to be exported to pdf. pdfmake is awesome.Slangy
Ya the auto repeating feature is really awesome, but sometime its not working perfectly.The repeated header overlaps the content. @Enthrall do you know how to stop auto repeat table header ?Herlindaherm
A
4

jsPDF provide good support for tables using jsPDF-AutoTable plugin.

jsPDF and pdfmake are two javascript libraries widely used to generate pdf. I have used both and would like to share few points i observed:

jsPDF

  1. Performance is really good. I would able to generate PDF of 2000 pages in 5-6 seconds.
  2. It doesn't support utf-8 format i.e. you won't be able to render pdf in chinese, turkish and other languages.
  3. It doesn't support row break and table inside table.

pdfmake

  1. Performace is good if you are generating pdf of less than 40 pages. Performance degrade exponentially if you generate larged pdf. Almost kill the browser.
  2. Support utf-8 format.
  3. Support row break and table inside table.
  4. Easy to use.

You can make wise decision based on your requirement.

Anesthesia answered 29/8, 2017 at 12:25 Comment(1)
Note that jsPDF has now added support for utf-8 fonts and that jspdf-autotable now has supports for table inside tables and row breaks.Dragster
F
0

Bytescout PDF Generator SDK for Javascript might come in handy: http://bytescout.com/products/developer/pdfgeneratorsdkjs/index.html

Ensure that browser inconsistencies for your targeted devices are taken into account.

Fleece answered 23/1, 2014 at 11:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.