Actual best pdf generator for Rails 3.1 - ruby-on-rails

I need a pdf generator for Rails 3.1 application.Which one can you suggest.
I've tried Prawn but it seems me quite not easy for a beginner like me while PdfKit gives me several errors :|

I don't know if it is the best fit for you, but I've heard good things about Wicked PDF/wkhtmltopdf.

I've tried both Wicked Pdf and PdfKit but in Development mode they are extremely slows :( Any other suggestions?
Another (maybe dummy) question: using PdfKit for example, I've seen that it make and open pdf file into web browser,but is there a way to download file into my desktop?

Related

How to generate PDF forms in Ruby-on-Rails

I would like to generate PDF forms with radio buttons and submit buttons in it by using Ruby on Rails. Does anyone know if there is a Gem that can help with this task?
I've looked into
Prawn,
Wicked PDF, and
PDFKit
but they don't seem to have this feature. Currently I am just using Acrobat Pro to create my PDF and insert the form manually but would like to automate this with a Gem if possible.
Any help would be appreciated, thanks.
EDIT
I just found 2 gems that can help insert radio buttons, check boxes, etc. while generating a PDF in rails: prawn-blank and prawn-forms. It doesn't seem like they are being maintained anymore but they should still be useful. Hope this is useful for others attempting to automate generating interactive PDF files too.
There's also RTeX. That works well if you're willing to translate to LaTeX first. LaTeX is a very good way to store marked-up documents. It just depends on how static each document is.
You can use right-signature to complete your task
https://github.com/rightsignature/rightsignature-api
http://www.gsubbarao.com/2013/03/ruby-rightsignature-api-to-prefill.html

How can I inject a dynamically generated image (barcode, as it happens) into a PDF document (I'm in rails if that matters)?

I'm aware of pdf-stamper, but I'm trying to avoid switching everything to jruby right now.
I just need to "stamp" an image that I generate within the rails app (a PDF417 barcode) into a form field in the PDF document (there's an FDF; it's a document template kinda thing).
I'm filling out the text-based fields by just shelling out to pdftk, so if there's a way to do it using pdftk, I'd be fine with that, but I've looked high and low for one without any luck.
How about using a barcode font? some alternatives too. I haven't used that one but there may be others available too
I know I'm late to the party, but the PDF417 Rubygem should do what you need. https://rubygems.org/gems/pdf417 will generate it and if you have chunky_png installed you can easily write out PNGs to a file.

generate PDF from html document in Rails

anyone knows about some gem or app in rails to create pdf docs from html5 and css3 with some client side programming??
Thanks ;)
Thank you for your responses. I need this for a possible project wich will use jquery for box positioning and then, will export the resultant html to pdf. Roughly, ¿is this possible?
PDFKit and WickedPDF for Client side generation, as suggested by Raphael and jcadam
Flying Saucer with JRuby: http://xhtmlrenderer.java.net
Personally, I got more accomplished by using Prawn PDF generator. It's capabilities are much more extensive, IMHO.
Prawn for Ruby PDF generation: https://github.com/prawnpdf/prawn
WickedPDF: https://github.com/mileszs/wicked_pdf
I'm using it now and rather like it:
"Wicked PDF uses the shell utility wkhtmltopdf to serve a PDF file to a user from HTML. In other words, rather than dealing with a PDF generation DSL of some sort, you simply write an HTML view as you would normally, then let Wicked take care of the hard stuff."
If you need more control, also check out Prawn: https://github.com/prawnpdf/prawn. Though Prawn is not an HTML -> PDF converter and is more useful for creating PDFs from scratch.
I'm using both Prawn and WickedPDF on my current project: WickedPDF to generate 'printable' versions of web pages, and Prawn for generating detailed PDF reports.
I believe the PDFKit gem may be what you're looking for.
https://github.com/pdfkit/PDFKit
There's also IMGKit if you want images instead of PDFs.
https://github.com/csquared/IMGKit

Pdf generation with latex in rails 3

is there a way to generate pdf documents from latex in rails 3? We've been using rtex (http://rtex.rubyforge.org/) in a rails 2 application, however it doesen't seem to work with rails 3.
Our rails application generates invoices using a latex template which we also use to create invoices by hand. Hence we would have to maintain two templates if we had to find a different solution for the pdf generation in rails 3.
Best I found to do such things was to create the .tex files on the server, then call a rake task that ran a "pdflatex" system command.
It is pretty poor in performances I guess, but it's designed for a single admin and works fine for me, on my local machine, and I can use the same latex templates for my letters
Old question, but I'm sure this'll help anyone coming to this page now.
Take a look at the rails-latex (LatexToPdf) gem.
The LatexToPdf.generate_pdf method takes in two arguments:
tex content
a configuration hash
...and returns the pdf binary, which you'll have to write to a file.
I suggest reading through the source to if you need to add configuration.
Note that under the hood, the rails-latex gem still depends on a TeX extension (which you'll need to download) to generate the pdf. The default is pdflatex, and I've personally used xelatex.
As of the writing of this answer, this gem is described as a renderer for rails 3; though it now includes support for rails 4 and 5.

Is Prince the best way to create PDFs in Ruby on Rails?

After several Google searches, it appears that the way to create PDFs in Rails from HTML and CSS (versus a new markup language) is to use Prince.
With licensing at $3800 for my non-big-commercial app, I'm wondering if this is, in fact, consensus or people have an alternative they can share the whats and hows.
You may check out prawn too. Tutorial can be found on railscasts.com.
This may fit the bill: http://code.google.com/p/wkhtmltopdf/
We tried tow solutions:
using latex generate pdf, there is ruby gem code rtex
using java library iText, use it you may need rjb which allow you using java lib directly in ruby code, just like jruby, but you don't need build all you application on jruby.
I create tons of different PDF files on the fly from various data sources using Rails, including finest layout. I create need to create them for presenting products to customers.
After having tried all the tools mentioned above, Prince is the best tool for this task.
Prince's rendering quality & CSS support (better than some browsers) is its main selling point. If you're only generating documents with simple layouts, stick with Prawn.

Resources