Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Use EM to display a .pdf #320

xb29 opened this Issue Apr 24, 2012 · 0 comments


None yet
2 participants

xb29 commented Apr 24, 2012

Hi all,

I am new to Rails and EM, and I am trying to accomplish a specific task asynchronously.

In my view, i have a button which invokes a method in my controller which is called "pdfreactor".
Its aim is to generate a .pdf (by launching a .bat which is doing some stuff...) and then to display the .pdf on the client side.
As it can last more than 15 seconds, i am trying to do it asynchronously by using EM, but my .pdf is not displayed.
This is my code :

def pdfreactor

some stuff

EventMachine::run do

my job

job = lambda do
system @my_bat_file #Generate a .pdf (path : @varwhichcontainapath)
test = @varwhichcontainapath
callback = lambda do |test|
# Open the .pdf file
send_file(test, :type => 'application/pdf')

EventMachine::defer job, callback

respond_to do |format|
format.html { redirect_to @my_url}


  • When I click on my button, i am redirect_to @my_url
  • The job works, my .pdf file is created
  • However, send_file does not display any .pdf on the client side (there is no error in my prompt and if I use the method synchronously with a file which is already created, my send_file syntax works)

As I am pretty new to the asynchronous development, I think I am missing something.
Do you have any idea about my prob ?


@tmm1 tmm1 closed this Feb 28, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment