Not able to marge 2 pdf dynamically using PDFmarger in php

80 Views Asked by At

I am getting error "This webpage is not available" while merging multiple PDF which generated dynamically using PDF marger.

Here is my code :

include_once(realpath($_SERVER['DOCUMENT_ROOT']).'/PDFMerger/PDFMerger.php');

    $pdf = new PDFMerger;

    $pdf->addPDF('\PDFEBS.pdf', 'all');
    $pdf->addPDF('\PDFHI.pdf', 'all');

    //echo $basepath.$post['fileName'];
    $pdf->merge('file',realpath($_SERVER['DOCUMENT_ROOT']).'\SamplePDF.pdf');
    return true;
1

There are 1 best solutions below

2
Scott On

Try adding the path before your PDF file includes like so:

$pdf->addPDF(realpath($_SERVER['DOCUMENT_ROOT']).'\PDFEBS.pdf', 'all');
$pdf->addPDF(realpath($_SERVER['DOCUMENT_ROOT']).'\PDFHI.pdf', 'all');

Assuming your realpath returns the right path of course.

And try reversing your slashes. \ => /