-
Notifications
You must be signed in to change notification settings - Fork 100
Description
Hi !
I am using the tcpdf lib to create pdf files with php. This is my code:
ob_start();
include ("layout.php");
$html = ob_get_contents();
ob_end_clean();
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$pdf->SetCreator("XXX");
$pdf->SetAuthor("XXX");
$pdf->SetTitle('XXX');
$pdf->SetSubject('XXX');
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
$pdf->SetMargins(1, 65, 1);
$pdf->SetHeaderMargin(0);
$pdf->SetFooterMargin(35);
$pdf->SetAutoPageBreak(TRUE, 45);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->SetFont('dejavusans', '', 10);
$pdf->AddPage();
$pdf->writeHTML($html, true, false, true, false, '');
This works fine and will generate a pdf file.
Now I would like to add an existing pdf file as second page.
I downloaded your files and put them in the correct directory. Than I replaced this line:
$pdf = new MYPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
to
$pdf = new TCPDI(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
After this modification I can create a pdf file like before = OK. Now I added this code part:
$pagecount = $pdf->setSourceFile("myOtherPDF.pdf');
for ($i = 1; $i <= $pagecount; $i++) {
$tplidx = $pdf->importPage($i);
$pdf->AddPage();
$pdf->useTemplate($tplidx);
}
But than I get only errors:
Fatal error: Uncaught Exception: TCPDF_PARSER ERROR: decodeFilterFlateDecode: invalid code in tcpdf/include/tcpdf_filters.php:474 Stack trace: #0 tcpdf/include/tcpdf_filters.php(359): TCPDF_FILTERS::Error('decodeFilterFla...') #1 tcpdf/include/tcpdf_filters.php(94): TCPDF_FILTERS::decodeFilterFlateDecode('\xAC@@)\xE9\r\x15C/y\x8F\x9B\x0F\x1C\xE9...') #2 tcpdf/tcpdi_parser.php(1333): TCPDF_FILTERS::decodeFilter('FlateDecode', '\xAC@@)\xE9\r\x15C/y\x8F\x9B\x0F\x1C\xE9...') #3 tcpdf/tcpdi_parser.php(1272): tcpdi_parser->_rebuildContentStream(Array) #4 tcpdf/tcpdi.php(210): tcpdi_parser->getContent() #5 functions.php(376): TCPDI->importPage(1) #6 /volume1/web/private/accounting/index.php(10): createPDF('240') #7 {main} thrown in tcpdf/include/tcpdf_filters.php on line 474