Connecting Tech Pros Worldwide Forums | Help | Site Map

Dynamic PDF Generation of HTML using PHP

mrquake99@gmx.de
Guest
 
Posts: n/a
#1: Apr 25 '06
Hi,

I am looking for php tools / scripts with which I can convert php
generated HTML to PDF. I was looking at FPDF and HTML2PDF (based on
FPDF). However, HTML2PDF can not handle nested lists and the output is
wrong. If I generate a PDF from:

<ul>
<li>L1</li>
<li>L2</li>
<ul>
<li>SL1</li>
</ul>
<li>L3</li>
</ul>

the ouput looks like:

- L1
- SL1
- L4

Maybe I did something wrong, but I could not find any error. Does
anybody know free php libraries cabable of handling nested lists?

Thanks a lot,

-- Frank


mrquake99@gmx.de
Guest
 
Posts: n/a
#2: Apr 25 '06

re: Dynamic PDF Generation of HTML using PHP


correction:

the output is:

- L1
- SL1
- L3

instead of

- L1
- L2
- SL1
- L3

-- Frank

strawberry
Guest
 
Posts: n/a
#3: Apr 25 '06

re: Dynamic PDF Generation of HTML using PHP


This from fpdf fourm...

Author: Muhammad Azeem Abbas (---.net.pk)
Date: 09-17-05 06:31

Use PHP str_replace(); Function before passing your HTML Tags to PDF.
Write

$html = str_replace( '<ul>', "" , $html );
$html = str_replace( '<li>', "->" , $html );
$html = str_replace( '</li>', "\n" , $html );
$html = str_replace( '</ul>', "" , $html );

Replace <li> tag with any character that shows a bullet, and replace
</li> to a new line.

HIH

Closed Thread