kartik-v / yii2-mpdf

A Yii2 wrapper component for the mPDF library which generates PDF files from UTF-8 encoded HTML.
http://demos.krajee.com/mpdf
Other
161 stars 150 forks source link

Adding some contents to existing PDF file. #55

Closed StarNeit closed 5 years ago

StarNeit commented 7 years ago

Hello.

I have got very long PDF document, but I want to change only one page from that one. I want to create new page and merge into existing pdf, but no luck yet.

I used below function in mPDF, but I want to know if i can do below functionality with this yii2-mpdf.

private function merge_PDFs( $files, $path ){

$pdf = new mPDF('', '', 0, '', 15, 15, 6, 12, 9, 9, 'P');
$pdf->enableImports = true;
foreach( $files as $file ){
    $pdf->SetImportUse();

    $pagecount = $pdf->SetSourceFile($file);
    for ($i=1; $i<=($pagecount); $i++) {
        $pdf->AddPage();
        $import_page = $pdf->ImportPage($i);
        $pdf->UseTemplate($import_page);
    }
}

$pdf_name = date('Y-m-d_His') . '.pdf';
$pdf_path = $path . $pdf_name;

//Make sure path exists
if (!file_exists($path)) {
    mkdir($path, 0777);
}

$pdf->Output($pdf_path, 'F');
unset($pdf);
return $pdf_path;

}

I only need to change few contents on very long PDF file, but I can not find good solution with this yii2-mpdf. If you someone helps me, then I will be very appreciate at that. Thank you.

junianto3695 commented 6 years ago

do you solve this? i have same problems too

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.