February 21st, 2013, 08:53 PM
PDF Line Breaks??
So far I have this code:
This code outputs invoice comments into the PDF. However, the comments stretch all the way to the right out of view. I have no idea how to actually put a line break in this. Also, I would like to contain this in a table if possible.
$_tempY = $this->y;
$this->y += 10;
$commentsCollection = $invoice->getCommentsCollection(true);
$internalcomments = "Internal Invoice Comments";
$page->drawText($internalcomments, 35, $this->y, 'UTF-8');
foreach($commentsCollection as $comm)
$page->drawText($comm->getData('comment'), 235, $this->y, 'UTF-8');
$this->y -= 10;
Any help would be greatly appreciated!
February 22nd, 2013, 12:52 AM
> $page->drawText($comm->getData('comment'), 235, $this->y, 'UTF-8');
So what does drawText do?
Or more specifically, what API are you using, and is there something like drawWrappedText which might offer you the ability to do some formatting.
If there is no higher level function, you might have to first do
$t = $comm->getData('comment');
- get the length of the text,
- chop $t into segments of up to 80 characters (however many fit on a line)
- then draw your list of segments in your loop.
> foreach($commentsCollection as $comm)
Are there limits on the length of each comment and the number of comments?
Would you need to consider spilling a lot of comment onto multiple PDF pages?