Reputation: 95
I'm getting fatal error:
Call to undefined method HTML2FPDF::FPDF() in C:\wamp\www\mycourse\html2fpdf\html2fpdf.php on line 149
when try to convert a html file to pdf using html2fpdf-3.0.2b.zip
.
I'm trying to convert a HTML file (mywebpage.html) into a Pdf file?
This is line 143:
$this->FPDF($orientation,$unit,$format);
and below is almost the whole function including line 143
function HTML2FPDF($orientation='P',$unit='mm',$format='A4')
{
//! @desc Constructor
//! @return An object (a class instance)
//Call parent constructor
$this->FPDF($orientation,$unit,$format);
//To make the function Footer() work properly
$this->AliasNbPages();
//Enable all tags as default
$this->DisableTags();
//Set default display preferences
$this->DisplayPreferences('');
//Initialization of the attributes
$this->SetFont('Arial','',11); // Changeable?(not yet...)
$this->lineheight = 5; // Related to FontSizePt == 11
$this->pgwidth = $this->fw - $this->lMargin - $this->rMargin ;
$this->SetFillColor(255);
$this->HREF='';
$this->titulo='';
$this->oldx=-1;
$this->oldy=-1;
$this->B=0;
$this->U=0;
$this->I=0;
Upvotes: 1
Views: 1888
Reputation: 11
I know this is an old question, and yes, this is a very old script, but I was able to solve this same problem today. So, in case someone else comes searching in the future, here is what solved it for me.
Edit the line:
//Call parent constructor
$this->FPDF($orientation,$unit,$format);
To be:
//Call parent constructor
parent::__construct($orientation,$unit,$format);
And you should be all set.
For the record, I also changed
function HTML2FPDF($orientation='P',$unit='mm',$format='A4')
To be
function __construct($orientation='P',$unit='mm',$format='A4')
In order to match the modern standards.
Upvotes: 1
Reputation:
http://pdfcrowd.com/web-html-to-pdf-php/
you cna try this for pdf conversion, it is one of the best html to pdf generator, and the library you are using is 12 years old,
Upvotes: 0
Reputation: 6159
I would definitely recommend using https://github.com/mikehaertl/phpwkhtmltopdf for any serious HTML to PDF conversion. Any other PHP Class that doesn't use the wkhtmltopdf engine has very poor support for CSS and would basically force you to use table design from the 90s to keep the correct layout.
I used wkhtmltopdf extensively a few years ago and it gave me very good results.
I would certainly not use a lib that is, according to this page, 12 years old... https://sourceforge.net/projects/html2fpdf/files/html2fpdf/
Upvotes: 0
Reputation: 133360
Your function names don't match you should use the same case sequence
function HTML2FPDF
html2fpdf
if you have function HTML2FPDF(..) call HTML2FPDF(...)
Upvotes: 0