1

Hi

I am trying to create a PDF document using HRML2PDF.
I have copied all the files and folders from the downloaded packed html2pdf-4.5.0 to /var/www/html except the folders example and test.
I have downloaded the composer.phar too and run the cmd: sudo php composer.phar install
No errors occurred.

When I run my php-code I receive the following error message: Fatal error: Class 'HTML2PDF_locale' not found in /var/www/html/html2pdf.class.php on line nnn
The class is defined in the local.class in the _class folder.
What am I missing in the code?

<?php
include("inc/conf.php");
require('html2pdf.class.php');
.
.
.
$pdf = new HTML2PDF('P','mm','A4');
$pdf->SetLeftMargin(1.0);
$pdf->SetRightMargin(1.0);
$pdf->SetTopMargin($topMargin);
$pdf->SetAutoPageBreak(true,$bottomMargin);
.
.
.
echo "</tr>";
echo "</table>";
echo "</body>";
echo "</html>";

$htmlbuffer=ob_get_contents(); // henter indholdet af bufferen
ob_end_clean(); // Stopper og sletter bufferen

$pdf->AddPage(); // Laver den første side
$pdf->WriteHTML($htmlbuffer); // skriver html til pdf siden

$file=basename(tempnam(getcwd(),'tmp'));
rename($file,"./tmp/".$file.'.pdf');
$file.='.pdf';
$pdf->Output($file);
.
.
.
?>

2

I've got the same error with Windows + Wamp with PHP 5.5.12

3

I found the problem I added those missing lines, in fichier html2pdf.class.php

require_once(dirname(__FILE__).'/_class/tcpdfConfig.php');
require_once(dirname(__FILE__).'/_class/locale.class.php');
require_once(dirname(__FILE__).'/_class/myPdf.class.php');
require_once(dirname(__FILE__).'/_class/exception.class.php');
require_once(dirname(__FILE__).'/_class/parsingCss.class.php');
require_once(dirname(__FILE__).'/_class/parsingHtml.class.php');

But now, the class "TCPDF" is missing in that line class HTML2PDF_myPdf extends TCPDF in that file myPdf.class.php

My html2pdf's version is 4.5.0

4

Hi, I had the same problem.

My solution was include:

require_once(dirname(__FILE__).'/_class/tcpdfConfig.php');
require_once(dirname(__FILE__).'/_class/locale.class.php');
require_once(dirname(__FILE__).'/_class/myPdf.class.php');
require_once(dirname(__FILE__).'/_class/exception.class.php');
require_once(dirname(__FILE__).'/_class/parsingCss.class.php');
require_once(dirname(__FILE__).'/_class/parsingHtml.class.php');

In all the pages where you have problem.

Follow me in my channel: https://www.youtube.com/channel/UCJx8FkIJT79n4TXoSdM-gEg

5

very bad solution

you have just to use composer...
Ancien pseudo : lolo

6

Hello,

Le mieux je crois est de retirer tous ces require et de ne mettre que celui-ci qui regroupe tout:

require('pdf/vendor/autoload.php');

A+
JC
avatar
Freelance web developer
Aix en Provence | London
jcdarocha.fr
contact@jcdarocha.fr