29136

Create PDF with Table using Javascript

Question:

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?

Answer1:

<em>Bytescout PDF Generator SDK for Javascript</em> might come in handy: <a href="http://bytescout.com/products/developer/pdfgeneratorsdkjs/index.html" rel="nofollow">http://bytescout.com/products/developer/pdfgeneratorsdkjs/index.html</a>

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

Answer2:

I wanted to use jsPDF to generate tables so I made a table plugin for it. Check it out! <a href="https://github.com/someatoms/jsPDF-AutoTable" rel="nofollow">jspdf-autotable</a> It has all the features I was looking for in a table plugin.

<ul><li>Auto width (100% of page width or only as much as required)</li> <li>Multiple pages</li> <li>Custom headers and footers</li> <li>Multiple tables on the same page</li> <li>Custom styling</li> <li><a href="https://someatoms.github.io/jsPDF-AutoTable/" rel="nofollow">Examples</a></li> </ul>

<img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/ZboAy.png" data-original="https://i.stack.imgur.com/ZboAy.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" />

Answer3:

<a href="http://pdfmake.org" rel="nofollow">pdfmake</a> 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 <a href="http://pdfmake.org/playground.html" rel="nofollow">the playground</a>

Answer4:

jsPDF provide good support for tables using <a href="https://github.com/simonbengtsson/jsPDF-AutoTable" rel="nofollow">jsPDF-AutoTable</a> 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:

<strong>jsPDF</strong>

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

<strong>pdfmake</strong>

<ol><li>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.</li> <li>Support utf-8 format.</li> <li>Support row break and table inside table.</li> <li>Easy to use.</li> </ol>

You can make wise decision based on your requirement.

Recommend

  • PHP directory separators, forcing forward slash; non-intrusive
  • PyGTK: gobject.idle_add() and timeout_add() with threads
  • Build an Xcode project on Windows
  • package ‘RTN’ is not available (for R version 3.0.1) [duplicate]
  • Install unixODBC >= 2.3.1 on Linux Redhat/CentOS for msodbcsql17
  • Can't build gem — native extension build fails — can you see why?
  • WCF to WCF Communication
  • How can i enable libmongoc ssl?
  • How to run pip3+git from behind proxy with docker?
  • Ensuring MAVEN_HOME is set correctly
  • Which WebSocket-based libraries work with React Native?
  • Mysql-dev for mac os
  • My Archetypes-based content type can't be added
  • How to submit universal application on iTunes?
  • How to install python-devel for 2.7 version after upgrade to python 2.7 on CentOS
  • WMV file in an ASP.NET page
  • How does git deal with identical branch names from two different remote repo?
  • How to build a 64-bit .NET DLL, with 64-bit COM interop?
  • Many versions of JDK: How do I specify which one is used?
  • Could not install package 'Microsoft.Owin.Security 2.0.1'
  • On which thread JavaFX change listeners are executed ?
  • UIBarButtonItem's action is not called when in a view with a UIGestureRecognizer
  • C++/CLI Thread synchronization including managed and unmanaged code
  • Meteor.. accounts- password— Create account on client without login
  • Generating anchors with PyYAML.dump()?
  • how to change api_token column in token guard
  • Configure Spring's MappingJacksonHttpMessageConverter
  • Getting unused unique values on a SQL table
  • using System.Speech.Synthesis with Windows10 universal app (XAML-C#)
  • How to autopopulate a field in SugarCRM form
  • UWP/C# - Issue with AQS and USB Devices
  • SetWindowsHookEx does not react on media keys
  • Alternative to overridePendingTransition() - Android
  • Atlas images wrong size on iPad iOS 9
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • Projection media query: browser support and workarounds?
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • WOWZA + RTMP + HTML5 Playback?
  • Why joiner is not used after Sequence generator or Update statergy
  • Android Heatmap on canvas or ImageView