How to create PDF from HTML?

How do I create a .pdf file efficiently from an HTML template in Rails?

Emanuele DelBono at Quora Visit the source

Was this solution helpful to you?

Other answers

There are options like prawn, but they rely on a specific DSL. I am guessing you would like to print a pdf version of an existing view. I would recommend looking into pdfkit. We have used it in the past, and although it has some issues, it works quite well. https://github.com/jdpace/PDFKit/

Abhishiv Saxena

You could also try http://docraptor.com. It works on a freemium model and is easy to use.

Josh Colter

Use an API like http://www.htm2pdf.co.uk/html-to-pdf-api - code samples in Ruby included.

Retze Faber

Try the http://www.web2pdfconvert.com/, which could convert the online webpage into PDF format and send to you via Email. What you need to do is just input the URL and click Convert.

Jasmin Jiang

I've found that proper usage of media queries for browser printing is the most effective. If you can't get the result you want: PDF Prawn is a good gem for rendering your data to PDF. I've tried a lot of pdf converters but they just tend to do a mediocre job. They also are a hassle. PDF has restrictions, so when I go to PDF I tend to rethink and ask 'what do these people really want to see in print'? People looking to print are typically looking for something very specific. Typically custom reports or charts will end up a better and efficient way to meet requirements.

Joshua White

If you want to use existing PDF as template, defining areas (bounds, name, type, ...) to be filled later (e.g. with values from Web form), you can use Dhek template editor. Created template is saved in open format (JSON), so it can be processed in any language (PHP, Python, Ruby, Java, .Net): https://github.com/applicius/dhek .

Applicius FR

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.