Using PDFLib
| From: | Nathan Mealey | Date: | Sun, 04 Apr 2004 18:56:12 +0000 |
| Subject: | Using PDFLib | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-182297@lists.php.net to get a copy of this message | ||
Hello,
I am trying to generate PDFs using PDFLib for the first time, and have two questions, one of which is very confusing to me.
1) how can I tell the script generating the pdf to store it in a particular place on the computer where the pdf generation is happening?
2) this is the really confusing one. The text being put into the body of the pdf is an article about 6300 characters. The tutorials I have found all follow the same format, and end up printing all of this text in one line (or row), so that the pdf ends up being just one line across. So the question is, how do I get the text to be placed normally on the page, so as to be a readable document? I should add that I am using a block of text sent from an HTML form.
Here is the PHP script:
<?php
$author=$_POST['author'];
$text=$_POST['text'];
$pdf = PDF_new();
PDF_open_file($pdf);
PDF_set_info($pdf, "author", "$author");
PDF_begin_page($pdf,612,792);
$font = PDF_findfont($pdf, "Helvetica", "winansi",0);
PDF_setfont($pdf,$font,12);
PDF_show_xy($pdf, "$text", 5,225);
PDF_end_page($pdf);
PDF_close($pdf);
$buffer = PDF_get_buffer($pdf);
header("Content-type: application/pdf");
header("Content-Length: ".strlen($buffer));
header("Content-Disposition: inline; filename=sample.pdf");
echo $buffer
?>
Thanks!
--
Nathan Mealey
Director of Operations
Cycle-Smart, Inc.
P.O. Box 1482
Northampton, MA
01061-1482
nathan@cycle-smart.com
(413) 587-3133
(413) 210-7984 Mobile
(512) 681-7043 Fax