Hi all,
I wish to create some PDF docs using pdflib on the server and send them
to a users browser.
I have a perl prog that creates my forms and its working OK but I dont
know how to deliver the output from the perl cgi script to the users
browser.
The PDFLib manual says that if the PDF_new() method is called without a
file name then the PDF doc is placed into memory and you call this using
PDF_get_buffer() and that this is used to send the PDF output to a users
browser but it does not give an example of how to send it (naturally
this is cgi stuff).
The prog to write the PDF works OK as I can write to a file instead and
open the file manually PDF in acrobat and its perfect.
Googling for "pdflib cgi" hasnt so far found me what I need - Im still
googling though.
--- PERL PROGRAM ---
#!/usr/bin/perl -w
use pdflib_pl 3.03;
my $p = PDF_new();
PDF_open_file($p, ""); # Generate PDF entirely in memory. See the PDFlib
manual.
# Here we write the pdf stuff...
PDF_close($p);
my $buf = PDF_get_buffer($p);
# Use the PDF data contained in the buffer buf
PDF_delete($p);
----------------------------
--- Simple CGI SCRIPT ---
#!/usr/bin/perl
use strict;
use CGI;
my $q = new CGI; # create new CGI object
print $q->header,
$q->start_html('hello world'),
$q->h1('hello world'),
print $q->a({href=>"out.pdf"}, "Your PDF File"); # this if its reading
from disk
print $q->a({href=>"???????"}, "Your PDF File"); # this if its reading
from memory
$q->end_html;
----------------------------------
Mike
--
--------------------------------------------------------------------
Michael Lake
Active caver, Linux enthusiast and interested in anything technical.
--------------------------------------------------------------------
--
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug