Ravish
Ravish

Reputation: 2421

using TCPDF and FPDI together

I have a doubt about using TCPDF and FPDI together. I am working on a project where I need to modify existing PDF file and generate new PDF, actually existing PDF are Greeting card template and I have to print certain data at certain pages (such as Image on first page, message on 3rd page, artwork on 4th page) to generate final PDF.

I googled and found with TCPDF, it is not possible to manipulate existing PDF, they suggested using FPDI for opening and manipulating existing PDF. That's where i am stuck. I need TCPDF (it methods to print images, transparent images, utf text, embed font etc) to do what I want to do, but, I need FPDI to start with. :(.

Please help me: is it possible to use both FPDI and TCPDF together? so that I can use features offered by both APIs ?

Thanks in advance...

Upvotes: 1

Views: 7723

Answers (2)

Joel Johnson
Joel Johnson

Reputation: 134

libraries_load('tcpdf');
libraries_load('fpdi');

$pdf = new FPDI();

$pdf->setSourceFile("%local_file_path%");

$tplIdx = $pdf->importPage(1);
$pdf->AddPage('L', array(3.5, 2), FALSE);
$pdf->useTemplate($tplIdx, 0, 0, 3.5, 2, false);

I was using Drupal at the time so I used libraries_load but require_once should work.

Upvotes: 0

space ranger
space ranger

Reputation: 422

http://www.setasign.de/products/pdf-php-solutions/fpdi/about/

"As of version 1.2.1 FPDI can be used with TCPDF - a derivate of FPDF."

Upvotes: 1

Related Questions