TCPDF_import is not bringing in an existing file

后端 未结 3 1351
情深已故
情深已故 2021-01-22 17:17

I have a PDF of a blank certificate, I want to fill in two lines when the user completes a course of study, and display the PDF so they can print or download it.

I am us

3条回答
  •  自闭症患者
    2021-01-22 17:57

    As stated in TCPDF_IMPORT documentation page at this time (2020-04-16)

    TCPDF_IMPORT !!! THIS CLASS IS UNDER DEVELOPMENT !!!

    Futhermore the free version of FPDI supports PDF up to version 1.4

    If someone else is looking for something that works easily with TCPDF, I used TCPDI from https://github.com/pauln/tcpdi. You can find some fork ready for composer too.

    The usage is quite simple and similar to FPDI. Here a snipped from my code. I have a privacy policy (a static PDF file) and want to save a copy with user name and agreement date in the footer of each page.

    // Create new PDF document
    $pdf = new TCPDI(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
    ...
    // Add the pages from the source file.
    $pagecount = $pdf->setSourceFile($localPrivacy);
    for ($i = 1; $i <= $pagecount; $i++) {
        $tplidx = $pdf->importPage($i);
        $pdf->AddPage();
        $pdf->useTemplate($tplidx);
        // Add agreement text in document footer
        $pdf->SetXY(15,282);
        $pdf->Cell(180, 5, "Documento approvato da {$fullName} il {$date}", 0, 0, 'C');
    }
    // Send PDF on output
    $pdf->Output(FOLDER_PATH . DIRECTORY_SEPARATOR . "{$userId}.pdf", 'F');
    

提交回复
热议问题