Printable Output

Posted on 2002-07-28
Last Modified: 2010-03-05
Does anyone have any advice about ways to make dynamic output from a CGI program which will print the same from any computer, as if it were a PDF file, for example.  

I'm creating an online program for managing conference guests and need to be able to print out guest cards that don't look like they are just printed off of the internet.

Thanks for the advice!
Alex Porter
Question by:alexswebsite
LVL 12

Expert Comment

ID: 7184240
the printer will anyway print the headers of your site if it is printed directly thru the browser.
LVL 10

Expert Comment

ID: 7185678
Did you try to create a PDF? It gives some work but gives what you need.

Try it.
LVL 10

Expert Comment

ID: 7185761
I'm not sure, but I have use this module.

the output will change computer to computer, but will be neer of what you need.
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.


Expert Comment

ID: 7190054

You can just output pdf's, gifs, jpegs, over the net straight from a perl script.  You open the a filehandle to the file in question, put it into binmode, and print it.  You just have to remember to print out the correct headers depending on what you are printing.



Expert Comment

ID: 7204673
If you want to dynamically insert text into the guest cards for printing without printing your website URL stuff that an HTML page gives you, you can make a file template and insert the text replacing the placeholders and then print that out.

The templates can be PDF (as other experts have said) and better yet RTF (rich text format), which is easier to manipulate.

The process is similar what mehdi said but you will need to use Perl's string replace functions to insert data.

You will need to make the guest card design in RTF or PDF first.

Accepted Solution

daluu earned 50 total points
ID: 7204875
try this:
perl script :
#author: David Luu
#Creation date: 8/6/2002

#Generate the headers to help a browser choose the correct application
print "Content-type: application/msword\n";
print "Content-Disposition: inline, filename=sample.rtf\n";

# Open template file
$filename = "sample.rtf";
open(TEMPLATE, $filename);

# Read the template into a variable
@output = <TEMPLATE>;

# Close template file

# Replace place holders in template with form data

$name = "David";

foreach $line (@output) {
     if($line =~ m/<<name>>/) {
          $line =~ s/<<name>>/$name/;

     # Send the generated document to the browser
     print $line;

And for a sample RTF file to use to test with this, go to

I couldn't get the script working on my server because of configuration problems (with CGIs) but it works if you execute it on the server thru the command line, but that won't display the RTF file in MS Word tho.

Personally, I prefer using PHP for web-based applications.

Author Comment

ID: 7205046
Thanks very much, and thanks to all for the helpful advice.  You've given me a lot to work with.

I appreciate it!
Alex Porter

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question