Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDFMerger with FPDI-PDF-PARSER

FPDI PDF Files merger is being used. However, I ran into the following issue while trying to merge PDF files versions 1.5 and higher. The following was the error I received:

This document (doc.pdf) probably uses a compression technique which is not supported by the free parser shipped with FPDI. (See https://www.setasign.com/fpdi-pdf-parser for more details)

I proceeded to visit the link, which advised to use the commercial addon fpdi-pdf-parser. This file is already included with the rest of the files. And in the installation steps, it is said that there are no other steps that are needed to be made, but I am still getting the same error.

It is worth noting that I am using the following PDF merger (which, in turn, uses the FPDI lib)

https://github.com/myokyawhtun/PDFMerger/blob/master/PDFMerger.php

I am not sure how I can use this "fpdi-pdf-parser addon", which is advertised to be a solution to my PDF 1.5 issue. What am I missing?

like image 580
hello_its_me Avatar asked Apr 17 '17 12:04

hello_its_me


1 Answers

You state that you are using PDFMerger, but looking at the project page shows:

Support of PDF 1.5 and PDF 1.6

FPDF and FPDI libraries replaced by TCPDF with TCPDI extension and parser.

So it would appear that, specifically because they don't support PDF versions >1.4, PDFMerger no longer uses FPDF and FPDI.

To test this I downloaded PDFMerger (note this includes a copy of TCPDF), slightly modified the example code, and ran it with a PDF that is marked as version 1.7:

<?php

include 'PDFMerger.php';

$pdf = new PDFMerger;

$pdf->addPDF('43451941a.pdf', '1'); // page 1 from first file.
$pdf->addPDF('43451941b.pdf', '5'); // page 5 from second file.

$pdf->merge('browser'); // send the file to the browser.

The result is that in my web browser I get a PDF file of two pages, as expected.

As far as I can tell FPDF/FPDI is not required at all!

Simply download and use PDFMerger.

like image 133
timclutton Avatar answered Sep 17 '22 14:09

timclutton