For some permission restriction, I can't install prawnto gem to my server. I used the method of http://blog.idyllic-software.com/blog/bid/204082/Creating-PDF-using-Prawn-in-Ruby-on-Rails to generate PDF for my object.
But, I used the method pdf.table to generate table, and this method is not accessible since I've remove prawnto.
Is there any method accessible to easily generate tables just with prawn gem ?
My application is on Rails 2.3.16, and prawn version 0.8.4.
Regards
Is there any reason to use prawn 0.8.4? If not then try to upgrade to latest prawn.
I am using prawn 0.12.0 and I can generate tables using pdf.table without prawnto gem.
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.
Hi I have an app which needs to render a PDF with access to controller variables like in view, and ideally also allow me to use partials. Currently I just have installed:
gem 'prawn'
gem 'prawn-table'
These work quite well, except for the fact that they do not allow for using partials.
After some reading I found some wrapper gems such as prawn-rails, prawn_rails (!) and prawnto or prawnto_2.
Does anyone have any experience with these gems and has a strong preference for any?
My Rails version: Rails 4.2.4
I'm using the Prawn gem (v 0.12.0, we can't use 2.0.0 because of compatibility issues) in a Ruby on Rails project. A user uploaded a PDF that they got directly from an official government website, so this is a PDF that we will have to handle for other users as well, but it is corrupt and crashes when Prawn tries to render it as a string. You can find the PDF in the "Certificate of Rent Paid" link on this page.
The error I'm getting with this PDF:
NoMethodError - undefined method 'size' for nil:NilClass:
And it's coming from this method in our Prawn gem:
def finalize
if dictionary.data[:Contents].is_a?(Array)
dictionary.data[:Contents].each do |stream|
stream.compress_stream if document.compression_enabled?
stream.data[:Length] = stream.stream.size # THIS LINE!!!
end
else
content.compress_stream if document.compression_enabled?
content.data[:Length] = content.stream.size # IT DOESN'T GET TO THIS
end
end
I'm stuck. The only tools I've been able to find through my searches to "fix" PDFs are Adobe Acrobat and PDFtk. PDFtk can be used in a server, but it's only for Windows and our server is running on a Linux server. I can't find any gems or any way around it. I was also able to "fix" the PDF by "Saving as PDF" from Google Chrome (v41) on a Mac (neither Windows nor Ubuntu Google Chrome worked). I want to be able to "fix" the PDF from within my Rails project though. Any thoughts/suggestions?
[EDIT] Using Ghostscript from the command line worked for me. This line: gs -o repaired.pdf -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress crp_14.pdf, "fixed" the PDF. Looking into the RGhost gem now to see if I can do the same thing from within a controller or model.
After Prawn dropped template support, I wrote a Ruby native gem called combine_pdf.
I can't test it with your file, but you might be able to load the PDF using the gem, render it to a string (or temporary file) and reload within Prawn.
OR, maybe it could help you move on to Prawn 2.0 (you can create new PDF data with Prawn and stamp it over an existing file with combine_pdf).
It's just a thought, don't kill me if it doesn't work ;-)
Good luck!
I am trying to create a xls file which includes charts with Ruby. We run ruby on rails in Unix environment(Debian). We currently use Spreadsheet gem. But this gem doesn't seem to have chart capability. Looks like Win32ole gem is for Windows only. Axlsx is more what I need but it works with xlsx files. Anyone know a better way of doing this? Thanks!
The writeexcel gem (github) supports xls and charts.
I want to generate reports in ruby on rails from any database table or result of join of two tables.
reports should be in different formats such as : pdf ,excel ,csv ,html etc..
Is this possible in rails 3.2.6.???
I know the ruport gem but don't know how to use it...
You can use a gem like Prawn. There's also a Railscast on how to get started, it's quite simple.
There are various gems are available for different kind of reports like below:
pdf - pdfkit gem, wkhtmltopdf gem, pdftk plugin
https://rubygems.org/gems/wkhtmltopdf
http://rubygems.org/gems/pdfkit
excel - spreadsheet gem
https://rubygems.org/gems/spreadsheet
csv - csv gem
http://rubygems.org/gems/fastercsv
etc..
You can use or utilize as per your requirements.