SitePoint Sponsor |
|
User Tag List
Results 1 to 12 of 12
Thread: Printer-Friendly Pages
-
Nov 21, 2007, 10:17 #1
- Join Date
- Oct 2007
- Location
- Texas
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Printer-Friendly Pages
I would like to be able to have my show methods display in a Printer-friendly format if I click a link to do so. Is there a plugin or easy way to accomplish this? Thanks.
Web design is cool. Roll with it.
-
Nov 21, 2007, 16:01 #2
- Join Date
- Feb 2006
- Location
- Worcs. UK
- Posts
- 404
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PDF is one way to go:
Rails PDF plug-in
or have a look at this article:
http://www.artima.com/rubycs/articles/pdf_writer.html
and here
http://ruby-pdf.rubyforge.org/pdf-writer/index.html
-
Nov 21, 2007, 16:58 #3
- Join Date
- Oct 2007
- Location
- Texas
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks
Web design is cool. Roll with it.
-
Nov 21, 2007, 18:25 #4
Could you not just use a printer stylesheet?
http://www.alistapart.com/articles/goingtoprint/
-
Nov 22, 2007, 05:50 #5
- Join Date
- Feb 2006
- Location
- Worcs. UK
- Posts
- 404
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Nice link Luke. I expects that a better way to go in this instance.
-
Nov 23, 2007, 10:25 #6
- Join Date
- Aug 2005
- Posts
- 986
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
A printer stylesheet is probably the way to go, but if you must show different html for printing you can add a content type and use something like this:
Code:respond_to do |format| format.print { ... } format.html { ... } end
-
Nov 23, 2007, 13:07 #7
- Join Date
- Feb 2006
- Location
- Worcs. UK
- Posts
- 404
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
According to the information on the page Luke linked to, you can specify the CSS via the HTML header info:
Code:<link rel="stylesheet" type="text/css" media="print" href="print.css" />
Interesting
-
Nov 23, 2007, 13:43 #8
If you want to serve up a PDF representation of a view, then there is no need to register a custom "print" mime/type; just use the PDF mimetype.
-
Nov 23, 2007, 21:38 #9
- Join Date
- Oct 2007
- Location
- Texas
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks Luke!
Web design is cool. Roll with it.
-
Nov 24, 2007, 05:26 #10
- Join Date
- Feb 2006
- Location
- Worcs. UK
- Posts
- 404
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
-
Nov 25, 2007, 06:55 #11
- Join Date
- Oct 2007
- Posts
- 21
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
There is a lot of debate over print stylesheet vs Separate layout vs PDF.
Using stylesheets is the PROPER way to do things (From a standards POV), as the File>Print feature works as expected. If you feel it necessary to use a "Print" link, use the document.print() javascript method.
If that isn't possible, a seperate layout is the next best option - for Rails 2.0 have a look at my blog post about aliasing formats.
Avoid PDF generation - it's too server intensive, requires a plug-in and is generally annoying to the end-user.
Hope that helps
-
Dec 20, 2007, 12:41 #12
- Join Date
- Oct 2007
- Location
- Texas
- Posts
- 25
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thanks Mad, I will check that out.
Web design is cool. Roll with it.
Bookmarks