Line break when using $pdf->text(....);

2,074 views
Skip to first unread message

frenkieb

unread,
Mar 23, 2010, 12:16:52 PM3/23/10
to dompdf
Hi,

I have a header on each page with some lines of text. I write this
text with $pdf->text(...).

How do I insert line breaks? Now I'm writing every line of text with a
separate $pdf->text(...) command like this:

$pdf->text(550, 40, $text1, $font, 9, array(0,0,0));
$pdf->text(550, 42, $text2, $font, 9, array(0,0,0));
$pdf->text(550, 51, $text3, $font, 9, array(0,0,0));
$pdf->text(550, 61, $text4, $font, 9, array(0,0,0));

I hope this can be done easier.

João Cândido de Souza Neto

unread,
Mar 23, 2010, 1:32:03 PM3/23/10
to dom...@googlegroups.com
As far as I know, DOMPDF reads a HTML code and generates a PDF file of it. So, if you want a line break, its better to use "<br>" in your HTML code.


23/03/10 13:16:52, frenkieb <fren...@gmail.com>:
--
You received this message because you are subscribed to the Google Groups "dompdf" group.
To post to this group, send email to dom...@googlegroups.com.
To unsubscribe from this group, send email to dompdf+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/dompdf?hl=en.

psychoactive

unread,
Mar 23, 2010, 2:15:46 PM3/23/10
to dompdf
yeah why aren't you just using html?

On Mar 23, 10:32 am, João Cândido de Souza Neto
<joaovargi...@gmail.com> wrote:
> As far as I know, DOMPDF reads a HTML code and generates a PDF file of it. So, if you want a line break, its better to use "<br>" in your HTML code.23/03/10 13:16:52, frenkieb <fren...@gmail.com>:Hi,

Ryan Masten

unread,
Mar 23, 2010, 3:09:44 PM3/23/10
to dom...@googlegroups.com
He is talking about in the HEADER which doesn't use HTML.

frenkieb

unread,
Mar 24, 2010, 3:44:54 AM3/24/10
to dompdf
Yeah, these line of text are in the header. I tried '<br>' and '\n\r'
etc. but that didn't break the line. Or is it possible to use html in
the header?

On Mar 23, 8:09 pm, Ryan Masten <ryan.mas...@gmail.com> wrote:
> He is talking about in the HEADER which doesn't use HTML.
>

> On Tue, Mar 23, 2010 at 1:15 PM, psychoactive <psychoact...@gmail.com>wrote:
>
> > yeah why aren't you just using html?
>
> > On Mar 23, 10:32 am, João Cândido de Souza Neto
> > <joaovargi...@gmail.com> wrote:
> > > As far as I know, DOMPDF reads a HTML code and generates a PDF file of
> > it. So, if you want a line break, its better to use "<br>" in your HTML

> > code.23/03/10 13:16:52, frenkieb <frenk...@gmail.com>:Hi,


> > > I have a header on each page with some lines of text. I write this
> > > text with $pdf->text(...).
> > > How do I insert line breaks? Now I'm writing every line of text with a
> > > separate $pdf->text(...) command like this:
> > > $pdf->text(550, 40, $text1, $font, 9, array(0,0,0));
> > > $pdf->text(550, 42, $text2, $font, 9, array(0,0,0));
> > > $pdf->text(550, 51, $text3, $font, 9, array(0,0,0));
> > > $pdf->text(550, 61, $text4, $font, 9, array(0,0,0));
> > > I hope this can be done easier.
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > "dompdf" group.
> > > To post to this group, send email to dom...@googlegroups.com.
> > > To unsubscribe from this group, send email to

> > dompdf+un...@googlegroups.com<dompdf%2Bunsu...@googlegroups.com>


> > .
> > > For more options, visit this group athttp://
> > groups.google.com/group/dompdf?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "dompdf" group.
> > To post to this group, send email to dom...@googlegroups.com.
> > To unsubscribe from this group, send email to

> > dompdf+un...@googlegroups.com<dompdf%2Bunsu...@googlegroups.com>

João Cândido de Souza Neto

unread,
Mar 24, 2010, 11:46:19 AM3/24/10
to dom...@googlegroups.com
I didn�t know that the head content were put in the pdf file.

24/03/10 04:44:54, frenkieb <fren...@gmail.com>:
Yeah, these line of text are in the header. I tried '<br>' and '\n\r'
etc. but that didn't break the line. Or is it possible to use html in
the header?

On Mar 23, 8:09 pm, Ryan Masten <ryan.mas...@gmail.com> wrote:
> He is talking about in the HEADER which doesn't use HTML.
>
> On Tue, Mar 23, 2010 at 1:15 PM, psychoactive <psychoact...@gmail.com>wrote:
>
> > yeah why aren't you just using html?
>
> > On Mar 23, 10:32 am, Jo�o C�ndido de Souza Neto
To unsubscribe from this group, send email to dompdf+un...@googlegroups.com.

BrianS

unread,
Mar 24, 2010, 1:56:34 PM3/24/10
to dompdf
You can only use HTML in the actual document. Doing any kind of
formatting using inline script is pretty much a manual process.

You could programmatically figure out where to break the line.
Something similar to what's discussed in this thread (but you'll have
to modify it to work with the header instead of footer):
http://groups.google.com/group/dompdf/browse_thread/thread/70a373b42d6e4cde

If you're up to hacking your code a little, you could add support for
fixed positioning. A proposed patch has been submitted that will add
fixed-positioning support. This would allow you to define your header/
footer in your actual HTML document instead of using inline script.
See the following:
http://code.google.com/p/dompdf/issues/detail?id=49

Reply all
Reply to author
Forward
0 new messages