pdf text

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

pdf text

Post 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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

wordwrap() or use "\r\n" at the end of each line.
User avatar
ddragas
Forum Contributor
Posts: 445
Joined: Sun Apr 18, 2004 4:01 pm

Post 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);

?>
Post Reply