Home » Php » FPDI merge PDF in url

FPDI merge PDF in url

Posted by: admin June 30, 2018 Leave a comment

use \setasign\Fpdi;


// define some files to concatenate
$files = array(
'Sample Book/1 p.front. (0).pdf',
'Sample Book/2 np..pdf.pdf',
'Sample Book/3 np..pdf.pdf'

// initiate FPDI
$pdf = new Fpdi\Fpdi();

// iterate through the files
foreach ($files AS $file) {
// get the page count

$pageCount = $pdf->setSourceFile($file);
// iterate through all pages

for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
    // import a page
    $templateId = $pdf->importPage($pageNo);
    // get the size of the imported page
    $size = $pdf->getTemplateSize($templateId);

    // add a page with the same orientation and size
    $pdf->AddPage($size['orientation'], $size);

    // use the imported page

    $pdf->SetXY(5, 5);

// Output the new PDF

Hello everyone, this is suppose a quick question; is it possible to put URL links like http://xwy.com/link_pdf/1.pdf, http://xwy.com/link_pdf/2.pdf and so on in $files variable as array?

I tried my best to understand and read the whole FPDI documentation but seems no lack.

The location for PDF goes on local only (filesystem) but how about remote URL where it contains pdf?

Thank you