0

I have downloaded PHP HTMLtoPDF converter from here. But when tried to just print single line output, it does not print in the output pdf. Its empty.

Below is the code which i tried.

$content1 = "<page><a>Sample PDF file</a></page>";

    // convert in PDF
    require_once('/home/www/APIs/html2pdf_v4.03/html2pdf.class.php');
    try
    {
        $html2pdf = new HTML2PDF('P', 'A4', 'fr');
        $html2pdf->setModeDebug();
        $html2pdf->setDefaultFont('Arial');
        $html2pdf->writeHTML($content1);
        $html2pdf->Output('exemple00.pdf');
    }
    catch(HTML2PDF_exception $e) {
        echo $e;
        exit;
    }
logan
  • 7,946
  • 36
  • 114
  • 185

1 Answers1

1

Whenever I get into trouble with something I simplify. Exterminate all the possibilities that could hinder the workings of a program.

With this in mind I have looked at the website and, probably just like you, found a sample piece.

$html2pdf = new HTML2PDF('P','A4','fr');
$html2pdf->WriteHTML("text");
$html2pdf->Output('exemple.pdf');

Try this and see if it works. Why? This is the simplest of setups. If this does not work you know it's not you (or your refrence to the class is wrong).

What I know from the pdf to html creators is that they all have a problem converting incorrect html to a pdf. In this case your "a" could be interpreted as wrong seeing it has no href (which could be required).

So to make this simple use a single line of string text without html like "test" and check back with us. But if that doesn't work I's probably suggest using another of the converters (which I would recommend anyway).

BTW, I use https://github.com/dompdf/dompdf which is very advanced in html error detection and common options.

Matt
  • 1,081
  • 15
  • 27
  • DOMPDF require any physical installation or shall directly place under any directory and use it ? – logan Jun 21 '14 at 14:27
  • 1
    Dom pdf is just like html2pdf. It is a class, only with better html error catching and a lot more function. Check the link. The performance and workings kind made me happy in the pants. – Matt Jun 21 '14 at 14:29
  • Why would it not work in all languages. It's a pdf creator with a heavy community behind it.hat language it produces is up to what you input into it. But I'm not the sales guy for this thing, have a look at the link. – Matt Jun 21 '14 at 14:36
  • I accept this answer for DOMPDF link. the file is coming as download option. i would like to save it in a location., – logan Jun 21 '14 at 15:35
  • I could not find latest version 0.6.2 download link. Only 0.6.1 is available. I saw unicode font issues are resolved in V0.6.2 version only. so i need that link. Could you please help ? – logan Jun 28 '14 at 18:33