Best way to deliver PDF reports?

4,307 views
Skip to first unread message

Gustavo Madruga

unread,
Jul 10, 2013, 2:37:41 PM7/10/13
to meteo...@googlegroups.com
Hi all, 

My need is basically export the user data in a tabular way in PDF.

I found 3 possible ways:
  • PDFKit npm, but then I'll have to manually create the table (the lines, rectangles, etc). Could be done, but I guess it's too much work.
  • Generating the report in plain HTML and then export it to PDF using PhantomJS.
  • Using Jasper Report/iReport in a Java applet somehow

I'm leaning towards the plain HTML with PhantomJS.

But what you guys think?

Is this the way to go or there is some better/easier way to achieve this?

Thanks,
Gustavo Madruga

steeve

unread,
Jul 11, 2013, 10:08:07 AM7/11/13
to meteo...@googlegroups.com
PDFKit looks like it is server side, so do you really need to go back to the server?  

Using PhantomJS I think you are restricted to the whole page and not just say a div that might be a specific report the user is downloading?

I was using jsLabel2PDF ( https://code.google.com/p/jslabel2pdf/ ) for PDF labels client side which I felt was a more responsive way of doing it.  It allowed my users to download pdf's of labels to print from a printer. You might be able to gank code from this project and create a simple div2PDF package unless one already exists.

You should not have to use a Java applet to create a PDF.

Steeve

mariano crowe

unread,
Jul 11, 2013, 10:55:24 AM7/11/13
to meteo...@googlegroups.com
I've been using wkhtmltopdf to generate pdfs from a web pages. It's a command line tool, that gets the url and some parameters, and returns a pdf file.
Then you can use something like this, this or even this, from inside your app.


--
You received this message because you are subscribed to the Google Groups "meteor-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to meteor-talk...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Chris Milham

unread,
Jul 15, 2013, 3:54:14 AM7/15/13
to meteo...@googlegroups.com
Hi Gustavo,

For basic stuff jsPDF (http://jspdf.com/) works OK client-side. I was using this for a while, until I tried to convert some reports which were using HTML for layout and originally generated by TCPDF in PHP. I couldn't find a client-side library that did a good job of HTML to PDF. Because I have little time and no budget, I didn't want to muck around with absolute positioning in a PDF, and paying for an online service for HTML to PDF conversion isn't an option right now. Because you're working with tables, you'll probably find this way painful too. The upside is that client side generation is super-fast.

I went with an approach of generating HTML using Server-side Meteor, then posting that (via Meteor.Http.call) to a small PHP wrapper around mPDF (http://www.mpdf1.com/mpdf/) living on another server. It then returns the PDF to the Meteor server, which sends it back to the client. I used mPDF this as it has much better CSS handling than TCPDF. Tables are excellent.

It's not ideal as was trying to stick with JS and keep everything self-contained in the Meteor app. But, it works for the small volumes of data I'm dealing with. 

Let us all know what you settle on, and why. All the best.

Chris Milham


Chris Hitchcott

unread,
Nov 16, 2014, 3:39:14 AM11/16/14
to meteo...@googlegroups.com
It really depends on your use case and environment, but just to add a suggestion: I have sometimes been okay with simply using the browser's print function.

Basically you apply a print-only stylesheet (you can do quite a lot with CSS in terms of pagination etc -- see http://davidwalsh.name/css-page-breaks). Then create a button the fires the printing function.

Voila; chrome does all the hard work of generating the PDF.

Again, only works for some specific cases, but worth thinking about.

Chris

Abigail Watson

unread,
Nov 16, 2014, 10:47:57 AM11/16/14
to meteo...@googlegroups.com
Easier method:

Add a print.css stylesheet, specify a @media print media rule, and use the browser's default Print functionality, and Print to PDF.  

Abigail Watson

unread,
Nov 16, 2014, 10:49:02 AM11/16/14
to meteo...@googlegroups.com
Ooops.  Didn't see Chris's response.  But, yes... +1 to what Chris said.  

Xanatas

unread,
Nov 17, 2014, 11:29:46 AM11/17/14
to meteo...@googlegroups.com
Im using http://pdfmake.org/

it generates client side the PDF with a sort of css syntax function.
it uses pdfkit though.

i only need it client side.

Joshua Bechard

unread,
Nov 18, 2014, 9:28:22 AM11/18/14
to meteo...@googlegroups.com
Also, I've been using tableExport (if your exporting a table) it is great and really easy to setup with Meteor. 

Gabriel Anderson

unread,
Nov 18, 2014, 11:40:44 AM11/18/14
to meteo...@googlegroups.com
+1 for pdfmake
Reply all
Reply to author
Forward
Message has been deleted
0 new messages