Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Printable Output

Posted on 2002-07-28
7
Medium Priority
?
225 Views
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
0
Comment
Question by:alexswebsite
7 Comments
 
LVL 12

Expert Comment

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

Expert Comment

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

Try it.
0
 
LVL 10

Expert Comment

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

http://search.cpan.org/search?dist=PDF-API2-0.2.3.8_fix

the output will change computer to computer, but will be neer of what you need.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Expert Comment

by:mehdi
ID: 7190054
alexswebsite,

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.

Cheers,

M
0
 
LVL 4

Expert Comment

by:daluu
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.
0
 
LVL 4

Accepted Solution

by:
daluu earned 200 total points
ID: 7204875
try this:
perl script :
------------------------------
#!/usr/bin/perl
#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
close(TEMPLATE);

# 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 http://www.engr.sjsu.edu/daluu/phprtf/sample.rtf

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.
0
 

Author Comment

by:alexswebsite
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
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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…
Six Sigma Control Plans

926 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