Google Answers Logo
View Question
 
Q: Creating a printer friendly page from a dynamic page ( Answered 4 out of 5 stars,   2 Comments )
Question  
Subject: Creating a printer friendly page from a dynamic page
Category: Computers > Programming
Asked by: schultz-ga
List Price: $10.00
Posted: 15 May 2002 15:33 PDT
Expires: 22 May 2002 15:33 PDT
Question ID: 16463
I work on a website which people can choose queries and get generated
reports with info from our database. The content looks fine on screen
but I would like to have a printer friendly page for them so the
printed
version is not cut off on the bottom (some reports are multiple
pages.)  It would be nice to have the
column headers on every page to make it easier to read.  This would be
simple if the page were static, then of course I could just format
another copy of the page and put a link.

Thanks, in advance for any help you may have.

Request for Question Clarification by roguedog-ga on 15 May 2002 15:45 PDT
Schultz,

What is the process by which you extract the information form the
database and present into web format? For instance, are you cold
fusion to do your database calls or are you using perl and xml.. or
any of the other myriad of possibilities for final front-end web
presentation.  Your answer as to how and what languages you use could
greatly help myself or another researcher understand and therefore
more accurately answer you query.

Thanks

RD
Answer  
Subject: Re: Creating a printer friendly page from a dynamic page
Answered By: larre-ga on 15 May 2002 18:52 PDT
Rated:4 out of 5 stars
 
Hi Schultz, 

The exact method used for printing of dynamic pages depends upon how
the pages are served.

Active Server Pages may be print formatted through the use of a header
and footer which detects the presence of desired print formatting
variable and serves the page in printer friendly format. Steven Smith,
of the ASP Alliance, explains this technique in the article: "Creating
a Print View for your Web Pages", ASP Alliance.com:

http://www.aspalliance.com/stevesmith/articles/printview.asp


Pages created with PHP, using MySQL or other databases, or UNIX
Server-Side Includes can most often utilize a CGI (Common Gateway
Interface) script to automatically format the page into
printer-freindly content. A printer-friendly link is included on the
dynamic page template. Clicking on the link calls the CGI script, and
the printer-friendly page is created and displayed on the fly.
Printer-friendly scripts DO require that you add beginning and ending
tags to your basic content, so that they know which portions of the
page to display for printing, and which to leave out, including your
column headers if that is desired. This can usually be accomodated in
the database page display template.


I've used both of the following CGI scripts for dynamic page printing,
and found both of them to be satisfactory. Both script sources offer
excellent customer service and professional installation assistance,
if needed.

Master PFP - a free script from Willmaster.com.

"Master PFP is an easy to install, easy to maintain CGI program
written with Perl 5 to provide your visitors with a printer friendly
version of your web page. ("PFP" stands for "Printer Friendly Page")
You place "begin" and "end" tags into your web page. The program uses
these to determine what to display on the page it generates for
printing. This method allows you to be selective about what the user
will print.

You can choose to display your images, replace your images with text
(such as "[image]"), or have the program hide your images.

Optionally, you display the source URL, as a clickable link, at the
top and/or bottom of the printer friendly page."

Willmaster.com, Master PFP, http://willmaster.com/master/pfp/


Advance Print - $29.95 from PerlOnline.com

"Offer a printer friendly page to your visitors. When your visitor
clicks on the printer icon, they will be presented with a page with no
navigation links, images or other items that the user does not require
to print.

Features

--Instantly create Printer Friendly pages 
--No Complex scripting to be setup, just add a link to the script on
the page and it becomes printer friendly.
--Add your own header, footer and copyright messages to the page. 
--Option to remove or keep pictures."

PerlOnline.com, Advance Print
http://www.perlonline.com/advprint/index.htm


Additional searching found two more sources for similar CGI scripts:

http://www.webmutant.com/autoprint.shtml
http://www.icthus.net/CGI-City/scripts-printer-friendly.shtml

Additional resources for writing CGI scripts of your own, or
installing scripts created by others may be found at:

http://cgi.resourceindex.com/Documentation/CGI_Tutorials/
http://directory.google.com/Top/Computers/Programming/Internet/CGI/Tutorials/

I'm guessing by the technical level of your question that you are
using one of the database methods outlined above. As an even more
universal solution however, you might investigate Apache's XML
Project's FOP (Formatting Objects Processor) which uses Java to read
source objects and then format output display.

http://xml.apache.org/fop/index.html

Search terms used: 

CGI Printer-friendly
://www.google.com/search?num=30&hl=en&client=googlet&q=CGI+printer-friendly+scripts
PHP Printer-friendly
://www.google.com/search?num=30&hl=en&client=googlet&q=PHP+printer+friendly+script
ASP printer-friendly

Hope this is useful to you.

larre-ga

Request for Answer Clarification by schultz-ga on 16 May 2002 09:39 PDT
I do the page in ColdFusion and use SQL to do the query.

Clarification of Answer by larre-ga on 16 May 2002 10:53 PDT
ColdFusion will accept standard HTML tags and pass them through the
server unchanged, however, you can also use a built-in capability of
Cold Fusion to create a new "printer-friendly" link, using the
CFOutput tag to generate a page with the query data formatted
specifically for printing.

CFML would be:

<CFOUTPUT QUERY="queryname" MAXROWS=n >
    Literal text, HTML tags, and
    dynamic field references (e.g., #FullName#)
</CFOUTPUT>

Here are directions  from Allaire's own Cold Fusion website which
should clarify the exact procedure to use in order to add a separate
output link to a "subset" of the query data:

http://www.houseoffusion.com/cfdocs1/Developing_Web_Applications_with_ColdFusion/12_Selecting_and_Presenting_Data/dwa12_06.htm

Here's a link to Cold Fusion users groups, forums, developer
information and publications.

http://www.cfug-md.org/cflinks.cfm

ColdFusion Custom Tags offers ready-to-use code for specific purposes.
I located one of their offerings: Print Block with Page Breaks, (cost
$5.00) that seems to be very close to what you're looking for.

Best of luck. 

larre-ga

Clarification of Answer by larre-ga on 16 May 2002 10:54 PDT
The direct link to Custom ColdFusion tags Page Break offering is:

http://www.cfcustomtags.com/subcategories.cfm?parentid=202
schultz-ga rated this answer:4 out of 5 stars
The answer gave me a little more understanding of what I was trying to
accomplish.  I received some other answers tied into that answer and
they were of help also.

Comments  
Subject: Re: Creating a printer friendly page from a dynamic page
From: mother-ga on 16 May 2002 09:17 PDT
 
You may also want to consider two other options, in addition to the
excellent suggestions given above.

Option 1: CSS to "clean up" for printing. This will avoid the "extra
link" to a printer-friendly unformatted version. You can use CSS to
remove extraneous printer choking colors, navigation, etc.

"CSS Beyond the Browser: Going to Print" by Eric Meyer. A List Apart.
May 10 2002-Issue No. 144.
http://www.alistapart.com/stories/goingtoprint/


Option 2: Auto-generate a PDF file "on the fly." This allows your user
to view the generated report data in a prescribed format, if they
choose click on an extra link to download (and print or just view) a
PDF file. Depending on whether you want your users to have these
reports in PDF format, this is a very popular but time-consuming
option. To get your dynamic reports into PDF format, you will have to
be using a scripting environment that has a PDF generating module
either built-in or that you can install. Just remember to pass your
user's search arguments in the "Download PDF" link.

Read over the following resources to determine if this is right for
you:

"Serving Dynamic PDF Files," By Godrey Nolan. New Architect, October
2000.
http://www.webtechniques.com/archives/2000/10/nolan/

PDFlib 
http://pdflib.org/pdflib/ 

"PHP for PDF," by Perugini Luca. PHP Builder.
http://phpbuilder.com/columns/perugini20001026.php3

Documentation for using PDFlib with PHP 
http://www.php.net/manual/en/ref.pdf.php

CPAN (Comprehensive Perl Archive Network) - search for PDF modules for
use with Perl
http://cpan.org/ 


Search strategy:

pdf "on the fly"
://www.google.com/search?sourceid=navclient&querytime=y64xwB&q=pdf+%22on+the+fly%22

css tutorial "media print"
://www.google.com/search?sourceid=navclient&querytime=y64xwB&q=css+tutorial+%22media+print%22


Good luck!
- mother-ga
Subject: Re: Creating a printer friendly page from a dynamic page
From: paola-ga on 02 Jun 2002 12:58 PDT
 
If the information is tabular, perhaps you could offer it as
a CSV file to download?  Searching for 'download CSV' on Google
finds a site offering data on a web page, as an Excel file
or as a CSV file:  http://www.bized.ac.uk/virtual/dc/

It'd mean writing CSV files to the server on deman (and having
a process to remove files older than a day, say).

You asked about repeating column headings at the top of pages.
The closest thing I can think of is that CSS2 allows page
breaks to be defined in printed pages:
http://www.w3.org/TR/REC-CSS2/page.html  However, since you
can't know what page size or orientation people'll be
printing pages, this doesn't seem that useful (and won't be
supported well yet anyway).

If your reports are already longer than a screenful, I
suggest that you repeat the column headings on the web
page version, for instance every 20 rows (or at natural
data breaks, whichever comes first) and again as the last
row.  This will make the web page easier to read whilst
making it more suited to printing.

In addition, Netscape (and Mozilla, I think) tend to keep
tables rows together when pages are printed.  You can
exploit this by starting a new table every "pageful".  (If
your reports aren't tabular, then put pagefuls of information
in single-cell tables on the understanding that this will
slow down display time for older browsers).

Using this multi-table approach in conjunction with repeated
column headings would mean a single template for both screen
and print.  You can then use CSS to use pt sizes (if you're
using px sizes) and to hide navigational elements (an approach
I used on a dynamic web site recently).


Paola

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy