2015-09-25 20 views
5

Vì vậy, tôi đang cố gắng sửa đổi một mẫu pdf với php.Lỗi FPDF: Mẫu không tồn tại! fpdf

Tôi nhìn xung quanh và phát hiện ra hầu hết mọi người sử dụng FPDI và tôi đã thử.

So What i làm là

include('pdf/fpdf.php'); 
include('pdf/fpdi.php'); 

// initiate FPDI 
$pdf = new FPDI(); 
// add a page 
$pdf->AddPage(); 
// set the sourcefile 
$pagecount = $pdf->setSourceFile('pdf/menu_blanka.pdf'); 
// import page 1 
$template = $pdf->importPage($pagecount); 
// use the imported page as the template 
$pdf->useTemplate($template, 0,0,0); 

Và tôi liên tục nhận được lỗi này "lỗi FPDF: Mẫu không tồn tại!".

Các bạn có thể giúp tôi không?

+2

Vasil, tôi hy vọng bạn đã tìm được giải pháp. Tôi gặp vấn đề tương tự khi cố gắng tạo lại ví dụ đơn giản FPDI tại đây: https://manuals.setasign.com/fpdi-manual/the-fpdi-class/examples/ –

+1

Tệp menu_blanka.pdf có tồn tại trong thư mục pdf không ? Tôi cho rằng kịch bản của bạn nằm trong thư mục mẹ của thư mục pdf? –

+0

Hãy thử gọi '' $ pdf-> AddPage(); '' * sau * '' $ pdf-> setSourceFile ('pdf/menu_blanka.pdf'); '' – kmoser

Trả lời

0

Đây là cách tôi đã đạt được điều này trong một dự án của tôi. Hoạt động tốt ..

require_once 'pdf/fpdf.php'; 
require_once 'pdf/fpdi.php'; 

$pdf = new FPDI(); 

$pdf->setSourceFile('/path/to/source.pdf'); 

$pdf->AddPage(); 
$tplidx = $pdf->ImportPage(1); 
$pdf->useTemplate($tplidx, 0, 0, 0);      

$output = $pdf->Output('output.pdf', "S"); 
Các vấn đề liên quan