On Wed, 2010-03-10 at 20:15 -0700, Craig White wrote:
> On Thu, 2010-03-11 at 03:19 +0100, John Wu wrote:
> > Thank you so much for your help!
> > 
> > I am finally able to install pdftk. I have a question about how to send 
> > pdf to browser directly.
> > 
> > my code is here:
> > 
> > pdf_output = `pdftk #{filename} fill_form #{fdf.path} output`
> > respond_to do |format|
> >     format.pdf do
> >         send_data pdf_output, :filename => filename,
> >                                  :type => "application/pdf"
> >     end
> > end
> > 
> > But the browser can not open the pdf. It says it is empty.
> > 
> > What is the correct way to do this?
> ----
> I've always used send_file myself, send_data might work but I have no
> experience with it but I think you're being sloppy with your command...
> 
> pdf_output = `pdftk some_file_name.pdf \
>                     fill_form some_file_name.fdf \
>                     output some_new_file_name.pdf`
> 
> send_file "some_new_file_name.pdf", 
>   :type => "application/pdf", 
>   :disposition => 'inline'
> 
> note that you will have to 'path' the pdf & fdf files all relative to
> the 'public' folder.
----
and perhaps I don't need to point this out because you've figured it out
already...

make sure you know EXACTLY what the fdf file is supposed to look like so
you can write it from rails.

make sure you test your fdf and pdf files with pdftk from the command
line so you know that they work before you worry about integrating into
rails.

you actually don't need pdftk and don't actually need to 'fill_form' if
you can put the PDF file on a web server that is accessible by Adobe
Reader because you can embed the URL for the PDF file inside the FDF
file and it will automatically download and do it's magic on the
client's computer.

Craig


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to