I'm working with a PHP script that writes a PDF file. My only problem is that you have to give it a page coordinate of where to start your text. When it gets to the end of the page, it simply cuts the text off and thats it- it has no form of text wrapping.
In the past, for a completely different thing, I have used the following code to cut a string at the nearest word to a set number of characters.
function nearestwordlink($len,$txt,$link){
if(strlen($txt)>$len){
$check="1";
while($check!=" "){
$check=substr($txt,$len-1,1);
$len--;
}
$txt=substr($txt,0,$len);
$txt.="...<br><a href=\"".$link."\">Read Full Story</a>";
}
return $txt;
}
I want to do a similar thing, but I want to create a new string starting where I left off, then chop it again if necessary and make another string.
I don't know if that makes sense, so I've put an example below of sortof what I want it to do. If anyone has any suggestions, or modifications to the above code that will let me do this I'd greatly appreciate it.
This is the text for the example right here. Let's say for an example that the character per line maximum was set to 45, the text block would turn into seperate strings not exceeding that value.
Where each color is a seperate string:
This is the text for the example right here.
Let's say for an example that the character
per line maximum was set to 45, the text
block would turn into seperate strings not
exceeding that value.
I'm going to put it right inside the pdf processing file, so I assume I could just do a loop and for each loop just echo the text to the pdf, instead of calling it as a function.
Any ideas?