Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

How can I create a new document using other PDFs that I'm generating?

I have methods to create some documents, and I want to merge them all in a big PDF, how can I do that with TCPDF?

I do not want to use other libs.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
726 views
Welcome To Ask or Share your Answers For Others

1 Answer

TCPDF has a tcpdf_import class, added in 2011, but it is still "under development". If you don't want to use anything outside of TCPDF, you're out of luck!

But FPDI is an excellent addition to TCPDF: it's like an addon. It's as simple as this:

require_once('tcpdf/tcpdf.php');
require_once('fpdi/fpdi.php'); // the addon

// FPDI extends the TCPDF class, so you keep all TCPDF functionality
$pdf = new FPDI(); 

$pdf->setSourceFile("document.pdf"); // must be pdf version 1.4 or below
// FPDI's importPage returns an object that you can insert with TCPDF's useTemplate
$pdf->useTemplate($pdf->importPage(1)); 

Done!

See also this question: TCPDF and FPDI with multiple pages


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...