I've been using the awesome prawn gem in my last few project, but this time I have to covert a odt file (in odf format) to PDF.
I know that there are many gems that can do this, for example docsplit and others, but since I am already using prawn to generate other PDFs in the same app I would really like to know if I could get a way without adding yet another pdf creator type gem...
Does anyone know any resources that could help? Or at least a (really) simple gem that coverts odt to PDF (without possibly having to install anything)?
Thanks in advance...
No, Prawn can't do that. Prawn is just a library for programmatically generating PDF documents.
Best way would be using LibreOffice in a head-less fashion to convert ODF files into PDF.
Related
I need to take a template (a pdf file) and add elements in it. I used prawn gem to generate a pdf with the elements and combine_pdf gem to combine this prawn pdf and the template. It works fine!
Now I need to add permissions to disable printing options. Prawn has an option for that but if I add it, I can't use combine_pdf to combine my template and this prawn pdf. Prawn can't start with an existing pdf (template system has been removed a long time ago...).
So I'm pretty stuck here, I looked everywhere in the web for a solution but couldn't find anything!
instead of combine_pdf gem you can use pdf-toolkit. it supports templating, combine pdf and set permissions. the manual can be found from here.
Looking for a way to parse a PDF (with just text in it), into the plain text. I see that PDF parsing with Ruby has been asked before but the answers are several years old, and not suited to a rails app.
Is there a gem that can assist with this?
This is what the docsplit gem is all about. Usage example:
pdfs = Dir['storage/originals/*.pdf']
Docsplit.extract_text(pdfs, :ocr => false)
Whats great with this gem is that it can convert .doc or .odt etc... to get the text.
Plus it's backed by a very specialised company: http://www.documentcloud.org/
This seems to be quite famous. I haven't tried it but it seems relevant.
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
So, I have wicked_pdf up and running, now I am wondering if I can password protect the pdf being generated so it is not easily editable. Is this possible? Perhaps a better question is can wkhtmltopdf generate a protected pdf?
If not, is there a great rails pdf gem or similar that can take an existing pdf and protect it?
Thanks!
Let me check the usage for wkhtmltopdf (v0.10.0 rc2).
Nope, at least not according to it's usage dump. And wicked_pdf just wraps wkhtmltopdf, so you're out of luck.
There are any number of OSS PDF projects floating around out there that could encrypt your PDF output in a second pass.
Can anybody show me (maybe copy/paste a simple code example) how to create the .pdf file from an existing (.xls) file, using the Prawn gem? (Basically, I'd need the command that "opens" the existing file.)
(I'm asking because the Prawn documentation (http://prawn.majesticseacreature.com/docs/) seems to be gone since quite a while - it's not even usable via Google cache...)
Thanks a lot for any help with this!
Tom
I'd suggest that you break the problem down.
Can you read xls with Ruby? Possibly, but it's flaky at best. However, you can easily read csv, and xls exports nicely to that format.
Can you write a 'table' of values to a prawn pdf? Yes
So, (almost) all you need is a little program that can parse a csv file into a prawn-friendly table-structure and then hand it off to Prawn for generation.
Turns out the Prawn gem cannot handle existing files...
Prawn can be used to render content on top of a PDF. You're talking about .xls, a completely different format.