# How to generate a pdf without pushing a button

**URL:** <https://www.ruby-forum.com/t/how-to-generate-a-pdf-without-pushing-a-button/132596>\
**Category:** Rails\
**Created:** [March 21, 2008, 6:39pm UTC](https://www.ruby-forum.com/t/how-to-generate-a-pdf-without-pushing-a-button/132596 "2008-03-21T18:39:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [March 21, 2008, 6:39pm UTC](https://www.ruby-forum.com/t/how-to-generate-a-pdf-without-pushing-a-button/132596/1 "2008-03-21T18:39:48Z")

</div>

I want to generate a pdf with pdf-writer. All the pdfs I have generated  
in past were like:

format.pdf do  
send\_data IncidenceDrawer.draw(@incidence, @logs, @relincs),  
:filename =\> ‘incidences/@incidence.id.pdf’, :type =\> ‘application/pdf’,  
:disposition =\> ‘inline’  
end

So, in that view, I had the link  
\<%= link\_to \_(‘PDF Format’), formatted\_incidence\_path(@incidence, :pdf)  
%\>

Only once I have pushed the link I generated the pdf. I want to generate  
it without pushing that button. I think I need some background magic, so  
I’m using BackgroundFu, but I can’t use the same code anymore, because  
it needs the button to be pushed.
