1
Vote

[PHPReport] Can't convert to PDF

description

Hi everybody,
I came here to see if you guys can help me.
I've discovered PHPExcel cause I'm using an class that uses PHPExcel ( PHPReport can be found: https://github.com/vernes/PHPReport)
And it works perfectly with the exception of PDF. Converts to HTML, excel and excel2003.
When it tries to convert to PDF it fails here:
 
File : Writer/PDF.php
 
line :47
    $pdfLibraryName = PHPExcel_Settings::getPdfRendererName();
 
    if (is_null($pdfLibraryName)) {
        throw new Exception("PDF Rendering library has not been defined.");
    }

comments

MarkBaker wrote Aug 8, 2012 at 10:35 PM

It looks as though PHPReport is using the latest github code.

This has removed the included 3rd-party tcPDF library (which didn't produce good output and was seriously bloated) and instead allows you to select whether you wish to use tcPDF, domPDF or mPDF as the PDF rendering library - your choice, but one where you must install the 3rd-party library yourself. Then, before using PHPExcel's PDF writer, you need to tell it which library you are using, and where it can find that library.

e.g.
//$rendererName = PHPExcel_Settings::PDF_RENDERER_MPDF;
$rendererName = PHPExcel_Settings::PDF_RENDERER_DOMPDF;
//$rendererLibrary = 'tcPDF5.9';
//$rendererLibrary = 'mPDF5.4';
$rendererLibrary = '/path/to/my/libraries/domPDF0.6.0beta3';

if (!PHPExcel_Settings::setPdfRenderer(
    $rendererName,
    $rendererLibraryPath
)) {
die(
    'NOTICE: Please set the $rendererName and $rendererLibraryPath values' .
    EOL .
    'at the top of this script as appropriate for your directory structure'
);
}

XicoXperto wrote Aug 9, 2012 at 12:13 PM

Thanks, I'll get into that...
I'll give news.

XicoXperto wrote Aug 9, 2012 at 12:50 PM

It seemed i couldn't make that to work.
I've just downloaded the domPDF at http://code.google.com/p/dompdf/ ( the 0.6.0 beta version ).
Then I've putted it in the same folder as the PHPExcel

So I've inserted that code, changed the path to "../dompdf/dompdf_config.inc.php" and then i got at the end of the function this data in the variables:

$pdfLibraryName = PDF_RENDERER_DOMPDF
$pdfLibraryPath = ../dompdf/dompdf_config.inc.php
$rendererName = PHPExcel_Writer_PDF_PDF_RENDERER_DOMPDF

and then it dies here:
$this->_renderer = new $rendererName($phpExcel);

Am I doing anything wrong?