Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PDF/PHP

Status
Not open for further replies.

jnxx

Programmer
May 18, 2005
14
0
0
GB
Hi all

Does anyone know where i could fiind info on how to set limits on how long a sentence can be before it goes to the next line on a page? I have the current code:

$pdf = pdf_new();
pdf_open_file($pdf, "createdpdf/mypdf.pdf");
pdf_set_info($pdf, "Author", "Ben Jonson");
pdf_set_info($pdf, "Title", "Creating a pdf");
pdf_set_info($pdf, "Creator", "Ben Jonson");
pdf_set_info($pdf, "Subject", "Creating a pdf");

pdf_begin_page($pdf, 595, 842,"");

$tahoma = pdf_findfont($pdf, "Tahoma", "host", 1);
pdf_setfont($pdf, $tahoma, 12);

pdf_show_xy($pdf, "<my very long text here>",0,700);
pdf_show_xy($pdf, "use in the document2.*/
",0,480);

pdf_end_page($pdf);
pdf_close($pdf);

The code works, but the text goes right across the page and is cut off, so you dont see all of the text. Is there some way of putting in a newline character or something equivalent?
Cheers
 
after consulting the php manual, I think i'd do something like this:

Code:
$longtext = "";//your text sample
$wrap = 100; //you could programmatically derive this from fontsize etc
$p1 = wordwrap($longtest, $wrap, '*||*');
$p2 = explode ('*||*',$p1);
pdf_set_text_pos($pdf,$x ,$y); 
foreach($p2 as $text):
 pdf_continue_text($pdf,$text);
endforeach;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top