TCPDF line breaks

TCPDF line breaks

am 23.12.2009 02:40:51 von Dave M G

PHP Users,

Anyone using TCPDF? I find that their own forums are near dead.

I want to accomplish something simple, but their documentation is far
from easy.

I have a PDF where I place text in various places around the page, like so:

$pdf->SetXY(50, 187);
$pdf->Write(0, "hello world");

However, in the case of really long text, the text spreads out to the
width of the page, which can break the formatting.

All I want to do is be able to constrain the width of the text being
written, ideally by number of characters, so that it will have line
breaks and form a column of text no wider than I want.

Is that possible with TCPDF?

Any advice would be much appreciated.

Thanks.

--
Dave M G

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: TCPDF line breaks

am 23.12.2009 04:10:09 von Paul M Foster

On Wed, Dec 23, 2009 at 10:40:51AM +0900, Dave M G wrote:

> PHP Users,
>
> Anyone using TCPDF? I find that their own forums are near dead.
>
> I want to accomplish something simple, but their documentation is far
> from easy.
>
> I have a PDF where I place text in various places around the page, like so:
>
> $pdf->SetXY(50, 187);
> $pdf->Write(0, "hello world");
>
> However, in the case of really long text, the text spreads out to the
> width of the page, which can break the formatting.
>
> All I want to do is be able to constrain the width of the text being
> written, ideally by number of characters, so that it will have line
> breaks and form a column of text no wider than I want.
>
> Is that possible with TCPDF?
>
> Any advice would be much appreciated.

In FPDF, I find I have to do $pdf->MultiCell() to accomplish this,
rather simply $pdf->Write() (it's kinda like a textarea in HTML).
There's probably something comparable in TCPDF.

Paul

--
Paul M. Foster

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: TCPDF line breaks [SOLVED]

am 23.12.2009 06:08:46 von Dave M G

Paul,

Thank you for replying.

> I find I have to do $pdf->MultiCell() to accomplish this

This turned out to be the command I needed.

I used:

$pdf->MultiCell(130,30,$text,0);

130 is the width, 30 the height, and the zero at the end means no border
(1 is a thin black border).

I've never been sure what units TCPDF works in, so I got the right
numbers by experimenting and dialling it in.

Thanks for the support!

--
Dave M G


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php