Extract page number from Word document - Ruby on Rails - ruby-on-rails

I'm working on an application that generates a .docx document using Caracal gem. I need a way to find out how many pages said document has, preferably directly from Caracal. Alternatively, I tried to use Yomu gem to get the page count from the metadata, as shown in this answer. However, apparently the document I'm generating does not include the page count in its metadata. Thanks in advance!

Related

Forbid printing on generated PDFs (via prawn + combine_pdf)

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.

Export as CSV and Excel in Ruby on Rails

I have a list of email-ids stored in a variabe ( Say #emails ). This list is being generated in a controller inside an action. This action is specifically made for this purpose. Now I want to enable the user to download this list other than viewing it as HTML. I am unable to find a way of doing it. (Also there is no model associated with emails so I think the approach described in Railscasts won't work here)
I've been using the axlsx_rails gem for this. Easy to install and to use.
https://github.com/randym/axlsx
for that follow these links:-
http://railscasts.com/episodes/362-exporting-csv-and-excel

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

Gem for surveys with images on RoR

I am a newbie on RoR and I am looking for a GEM that would create surveys and support images. I have tried Surveyor and it seems great for text only surveys (I will definitely use it again for surveys). Ideas?
Easiest way would be to generate the HTML with that gem, then use the generated HTML and put it in the html.erb and update it with the images.
You can look at the generated HTML with developer tools on your browser.
Otherwise, you will have to write it yourself or add new methods to that gem.

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.

Resources