rguedes / PDFMerger

PDFMerger compatible with PHP5 for laravel
34 stars 43 forks source link

PDFMerger not merging pdf file #14

Open nikunjgajera opened 5 years ago

nikunjgajera commented 5 years ago

I need to merge pdf file and create new pdf file but i get below exception

{
    "message": "Unable to find xref table.",
    "exception": [
        {
            "type": "Exception",
            "code": 0,
            "message": "Unable to find xref table.",
            "file": "\/var\/www\/app\/vendor\/rguedes\/pdfmerger\/Classes\/fpdi\/pdf_parser.php",
            "line": 330
        }
    ]
}

my composer.json file is below

 "require": {
        "php": ">=5.6",
        "ext-gd": "*",
        "composer/installers": "^1.4.0",
        "symfony/console": "^3.3",
        "wikimedia/composer-merge-plugin": "dev-master",
        "onelogin/php-saml": "^2.12",
        "fpdf/fpdf": "^1.81",
        "rguedes/pdfmerger": "dev-master"
    },

my php code is below

use PDFMerger;

$pdfMerger = new PDFMerger();

$pdfMerger->addPDF('test1.pdf');
$pdfMerger->addPDF('test2.pdf');
$pdfMerger->addPDF('test.pdf');

$pdfMerger->merge('merged.pdf');

let me know how to solve this exception?

LisaW9 commented 5 years ago

I think you need to specify the output option

See documentation:

$pdf->merge('file', 'samplepdfs/TEST2.pdf'); 

// REPLACE 'file' WITH 'browser', 'download', 'string', or 'file' for output options