Fritz Trapper
2010-Mar-19 18:43 UTC
How to save rails generated pages to a file on the server
My show view of a data form is finished and now I want to give a possibility to download this view as a pdf file. I would like to use HTMLDOC to convert the html text to pdf. My idea: save the html text to a temporary folder and run HTMLDOC. But how can I save the html text to a file? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Philip Hallstrom
2010-Mar-19 19:04 UTC
Re: How to save rails generated pages to a file on the server
On Mar 19, 2010, at 11:43 AM, Fritz Trapper wrote:> My show view of a data form is finished and now I want to give a > possibility to download this view as a pdf file. > > I would like to use HTMLDOC to convert the html text to pdf. My idea: > save the html text to a temporary folder and run HTMLDOC. > > But how can I save the html text to a file?render_to_string http://api.rubyonrails.org/classes/ActionController/Base.html#M000659 That puts it into a local variable anyway... if you can then pass that to htmldoc you''re on your way. Not sure how this might affect any paths to CSS/images for HTMLDOC though. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Fritz Trapper
2010-Mar-19 19:54 UTC
Re: How to save rails generated pages to a file on the server
Philip Hallstrom wrote:> render_to_string > > http://api.rubyonrails.org/classes/ActionController/Base.html#M000659 > > That puts it into a local variable anyway... if you can then pass that > to htmldoc you''re on your way. Not sure how this might affect any > paths to CSS/images for HTMLDOC though.Thanks. CSS is "no problem" with HTMLDOC - it doesn''t support it ;-) Maybe, I need to find some alternative for HTMLDOC. My problem is, that I have a table with variable number of columns. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Philip Hallstrom
2010-Mar-19 19:59 UTC
Re: Re: How to save rails generated pages to a file on the server
>> render_to_string >> >> http://api.rubyonrails.org/classes/ActionController/Base.html#M000659 >> >> That puts it into a local variable anyway... if you can then pass >> that >> to htmldoc you''re on your way. Not sure how this might affect any >> paths to CSS/images for HTMLDOC though. > > Thanks. CSS is "no problem" with HTMLDOC - it doesn''t support it ;-) > > Maybe, I need to find some alternative for HTMLDOC. My problem is, > that > I have a table with variable number of columns.Prawn. http://railscasts.com/episodes/153-pdfs-with-prawn -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jeff Lewis
2010-Mar-19 20:17 UTC
Re: How to save rails generated pages to a file on the server
You might want to check out: http://code.google.com/p/wkhtmltopdf/ http://www.princexml.com/ wkhtmltopdf is free. prince will cost you. prince has better css print-related implementation coverage at this time, but wkhtmltopdf can be a very good alternative depending on the needs of your project. Jeff On Mar 19, 12:54 pm, Fritz Trapper <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Philip Hallstrom wrote: > > render_to_string > > >http://api.rubyonrails.org/classes/ActionController/Base.html#M000659 > > > That puts it into a local variable anyway... if you can then pass that > > to htmldoc you''re on your way. Not sure how this might affect any > > paths to CSS/images for HTMLDOC though. > > Thanks. CSS is "no problem" with HTMLDOC - it doesn''t support it ;-) > > Maybe, I need to find some alternative for HTMLDOC. My problem is, that > I have a table with variable number of columns. > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Fritz Trapper
2010-Mar-19 20:45 UTC
Re: Re: How to save rails generated pages to a file on the server
Prawn seems to need a fixed number of columns in tables, so I''ll take a look on wkhtmltopdf. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jeff Lewis
2010-Mar-19 21:15 UTC
Re: How to save rails generated pages to a file on the server
Since I started using tools (like prince/wkhtmltopdf) to generate pdfs from html/css for web app projects that need to gen pdfs, I''ve never gone back to using low-level pdf-gen''ing libs/tools (like prawn). Just requires so much less work. By the way, you may also want to look into using http://www.accesspdf.com/pdftk/ in combination with wkhtmltopdf(/prince) in case you need to do any post-processing of your gen''d pdfs (adding additional watermarks, splitting out pdf pages, combining pdfs, ....). Jeff On Mar 19, 1:45 pm, Fritz Trapper <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Prawn seems to need a fixed number of columns in tables, so I''ll take a > look on wkhtmltopdf. > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.