HTML with Prawn

2019-07-13 03:14发布

问题:

Im trying to use prawn to generate a PDF of a log entry, then entries are stored in bbcode ([b]bold[/b] etc...) and is converted to html on display.

Is there any way to display the html in prawn?

回答1:

It sounds like prawn-format might be what you're looking for, but you'll need to use an older version of prawn if you want to try it out.



回答2:

You'll probably get the best results if you use a lexical analyser such as 'Syntax' by Jamis Buck (http://syntax.rubyforge.org/) and parse the interesting parts of the HTML chunk and render those parts to PDF.



回答3:

You can use http://www.princexml.com/ to convert html docs to css, or use the princely plugin to render a pdf as one of the accepted formats of your view. See http://jimneath.org/2009/02/16/creating-pdf-documents-in-ruby-on-rails/

If you are wanting to use prawn directly I don't think there is a way to just use html directly to convert to pdf.