I would like to generate PDF on an area I specify (like in a div id tag) I'ved started to use rails gem PDFKit by following the tutorial from railcast and the docs.
So a simple .pdf link did the trick.
<%= link_to 'Open PDF', invoice_path(@invoice, :format => "pdf"), :class => "btn btn-md btn-primary" %>
Now the issue is how do I capture just the wanted area ? I explored html answers here: Print <div id=printarea></div> only?
I tried something like this and it doesnt work.
@media print
{
body * { visibility: hidden; }
#printableArea * { visibility: visible; }
#printableArea { position: absolute; top: 40px; left: 30px; }
}
in show.html.erb
<div id="printableArea">
something in PDF
</div>
I found some other resource, like this http://www.sitepoint.com/pdf-generation-rails/ but it just ask to put tags to hide it. My problem is more to hide the rest and make the div i want visible.