Dynamic PDF Generation of HTML using PHP

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mrquake99@gmx.de

    Dynamic PDF Generation of HTML using PHP

    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

    #2
    Re: Dynamic PDF Generation of HTML using PHP

    correction:

    the output is:

    - L1
    - SL1
    - L3

    instead of

    - L1
    - L2
    - SL1
    - L3

    -- Frank

    Comment

    • strawberry

      #3
      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

      Comment

      Working...