Not able to marge 2 pdf dynamically using PDFmarger in php

235

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;
556

Answer

Solution:

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. \ => /

People are also looking for solutions to the problem: php - preg_match_all on the same line

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.