pauln / tcpdi_parser

Parser for use with TCPDI, based on TCPDF_PARSER
GNU Lesser General Public License v3.0
27 stars 47 forks source link

Blank page when writing on a v.1.5 PDF file #18

Open nettunodev opened 7 years ago

nettunodev commented 7 years ago

Hi,

I'm trying to write on a PDF file v.1.5, but it doesn't work. The original file has 7 pages, the new one has only one blank page except for a black line on the top. For privacy reason I can't attach the file.

I'm using a try - catch block to catch exceptions but I don't get any error... Here is my code: ` require('../../../lib/tcpdf/tcpdf.php'); require('../../../lib/tcpdf/tcpdi.php'); try{ $pdf = new TCPDI(); $pageCount = $pdf->setSourceData($content);

$pdf->SetDrawColor(255,0,0);
$pdf->SetTextColor(255,0,0);
$pdf->SetPrintFooter(false);

$pdf->SetFont('helvetica','',8);

for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
    $tplIdx = $pdf->importPage($pageNo);

    $size = $pdf->getTemplateSize($tplIdx);
    $w = $size[w];
    $h = $size[h];

    if ($h > $w ){ // Il PDF è Portrait 
        $pdf->AddPage("P");
    }else{  // Il PDF è Landscape
        $pdf->AddPage("L");
    }

    $pdf->useTemplate($tplIdx);                         
    $pdf->SetXY(0.2,5,true);
    $larghezzaFoglio = $pdf->getPageWidth();
    $pdf->Cell($larghezzaFoglio-0.4, 5, "  ".$stringaTimbro, 1,1,'L');
}
$pdf->Output($name, "D");

} catch (Exception $e) {
echo($e); } `

I'm using FPDF_TPL - Version 1.2.3, TCPDF Version 6.2.12, TCPDF parser Version 1.0.16, TCPDI parser Version 1.1, TCPDI - Version 1.0. Please let me know if you need more informations.