Michael Lake wrote:
> I wish to create some PDF docs using pdflib on the server and send them
> to a users browser.
.....
I have added the following bit of code...
my $p = PDF_new(); # must be matched with a PDF_delete !
# Generate PDF entirely in memory. See the manual.
PDF_open_file($p, ""); # Dont forget to call PDF_close($p) later;
pdf_info();
pdf_singlepage_test();
PDF_close($p);
# Save the PDF data contained in the buffer then clear the buffer.
$document = PDF_get_buffer($p);
PDF_delete($p);
# Send the doc to the users browser.
my $length = length ($document); print length;
my $filename = "out.pdf";
my $q = new CGI; # create new CGI object
# create the HTTP header
print $q->header(-type=>"Content-Type: application/pdf",
-length=>"$length",
-disposition=>'inline; filename="$filename"');
print $q->start_html('hello world'), "\n"; # start the HTML
#print $q->h1('hello world'), "\n"; # level 1 header
print $document;
Now I am getting binary data returned to the users browser as text :-(
I prob have something wrong with the HTML headers.
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
lang="en-US"><head><title>hello world</title>
</head><body>
%PDF-1.3
%����
5 0 obj
<</Length 6 0 R
/Filter/FlateDecode
etc....
>>
startxref
1260
%%EOF
</body></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