dongwei2983 2018-07-07 18:46
浏览 98

MPDF错误:无法在预期位置找到对象(4,0)

I have some PHP pages and PDF that I need to merge into a single PDF file. I am using the MPDF library but I am getting the following error:

"Unable to find object (4, 0) at expected location."

This is my code:

<?php

function pdf_recreate($f)
{
    rename($f, str_replace('.pdf', '_.pdf', $f));

    $fileArray = [str_replace('.pdf', '.pdf', $f)];
    $outputName = $f;
    $cmd = "gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=$outputName ";

    foreach ($fileArray as $file) {
        $cmd .= $file . " ";
    }

    $result = shell_exec($cmd);
    //unlink(str_replace('.pdf','_.pdf',$f));
}

$new_pdf_recreate = pdf_recreate('../upload_dir/testPDF.pdf');

try {

    $mpdf = new \Mpdf\Mpdf();
    $mpdf->setFooter('{PAGENO}');
    $mpdf->SetImportUse();

    // Create Initial Invoice PDF
    $mpdf->WriteHTML($content);

    // import C.pdf
    // $pagecount = $mpdf->SetSourceFile(dirname(__FILE__).'/C.pdf');
    $pagecount = $mpdf->SetSourceFile(dirname(__FILE__) . $new_pdf_recreate);

    //Loop through the pages adding them to the PDF
    for ($i = 1; $i <= $pagecount; $i++) {
        $mpdf->AddPage('');
        $import_page = $mpdf->ImportPage($i);
        $mpdf->UseTemplate($import_page);
    }

    $mpdf->Output();

} catch (\Mpdf\MpdfException $e) {
    echo $e->getMessage();
}

Can anyone tell me why am getting this message/error?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b
    • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
    • ¥500 火焰左右视图、视差(基于双目相机)
    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号