Page 1 of 1
pdf text
Posted: Sun Apr 24, 2005 2:54 pm
by ddragas
Hi all
I'm retriving some text from database, and this text can be very long. When I want to write this text on pdf page, it is written all in one line, and it exits out of page margin
How can I make it to write it all on page like on MS Word?
Please help.
Regards ddragas
Posted: Sun Apr 24, 2005 3:00 pm
by Chris Corbyn
wordwrap() or use "\r\n" at the end of each line.
Posted: Sun Apr 24, 2005 3:33 pm
by ddragas
It is not working
Please take a look at the code
Here is complete code
Code: Select all
<?
$email_posiljatelja = "mail@mail.com";
$datum = "01.01.01";
$smjestaj = "0412345613";
$tema = "Subject";
$poruka = "
PHP and COM
If you're an adventurous soul, and you're running PHP on Windows using the CGI, ISAPI or Apache module version, you can
access the COM functions. Now, explaining COM (Microsoft's Component Object Model) is left to Microsoft and very large
books. However, for a little taste of what COM can do, here's a common (no pun intended) code snippet.";
$p = PDF_new();
PDF_open_file($p);
PDF_begin_page($p,595,842);
$font = PDF_findfont($p,"Helvetica","host",0);
PDF_setfont($p,$font,9.0);
pdf_show_xy($p, "Pošiljatelj: ", 50,780);
pdf_show_xy($p, "Poruka poslana: ", 50,770);
pdf_show_xy($p, "Veza smještaj: ", 50,760);
pdf_show_xy($p, "Tema poruke: ", 50,740);
pdf_show_xy($p, "Poruka: ", 50,730);
pdf_show_xy($p, $email_posiljatelja, 130,780);
pdf_show_xy($p, $datum, 130,770);
pdf_show_xy($p, $smjestaj, 130,760);
pdf_show_xy($p, $tema, 130,740);
$newtext = wordwrap($poruka, 20, "\n", 1);
pdf_show_xy($p, $newtext, 50,720);
PDF_end_page($p);
PDF_close($p);
$buf = PDF_get_buffer($p);
$len = strlen($buf);
$file = "somefile.pdf";
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline, filename=$file");
echo $buf;
PDF_delete($p);
?>