Prakadeessh Arunachalam Prakadeessh Arunachalam - 3 months ago 15
HTML Question

Insert a footer in all pages while exporting to word from rails

I am building a rails app. I use the gem "htmltoword" to export to Word document.

The number of pages in the exported doc depends on the no:of records in the DB. I want a content in footer in all the pages of the exported document.

Is there any way to do this?

Answer

You linked to a no longer maintained version of htmltoword, check this one. You can use views to render your document in an action (or even without an action by instanciating an ActionView directly yourself), and you can define partials for anything you want, and put a footer inside if it takes on page each time.

For Word specific footer it could a bit more complicated, but maybe using a HTML table to display your data and use a tfoot at the beginning the gem will be able to do that for you.

Another solution if you're looking for print is to generate your document in another format, e.g. tex