Ajay wrote:> How to load pdf file in browser using rails and how to store it in
> MySQL database using same?
I use PDFWriter to generate PDF reports, and the controller for a model
handles the call for creation by the model and routing it to the users
browser, like this (mode is a param value that tells the model if the
user requested the long or short form of the report, the renderOnPdf is
the model method to gen the pdf, construct a filename for the PDF, and
send_data send it to the user):
def pdf
@project = Project.find(params[:id])
mode = params[:mode]
pdf = PDF::Writer.new
pdf.start_page_numbering(300, 20, 10, :center, nil, nil)
@project.renderOnPdf( mode, "no", pdf )
pdf.stop_page_numbering( true, :current )
x_now = Time.now
x_filename =
@project.projname+"-"+x_now.strftime("%Y-%m-%d-%H%M")+".pdf"
send_data pdf.render, :filename => x_filename, :type =>
"application/pdf"
end
I don''t store my PDFs in the database, but I assume it''d just
be a blob.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---