PDFMerger with FPDI-PDF-PARSER
Asked Answered
G

1

13

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?

Ghiselin answered 17/4, 2017 at 12:55 Comment(10)
open you pdf file with text editor and paste the content here.Ogburn
@anwerjunaid The content of the pdf file is irrelevant as my problem is with the multiple pdf files regardless the content to be merged together using PDFMerger.Ghiselin
not the contents, you may need yo check binary part of files. there are different ways how pdf can be generated.Ogburn
There is example of compressed pdfs in the official document setasign.com/products/fpdi-pdf-parser/detailsPegeen
@AgamBanga I did not find the example clear, especially that I have no php experience.Ghiselin
Can you paste your code?Pegeen
Have you tried this manuals.setasign.com/fpdi-pdf-parser-manual/installationVerticillate
@AhmedGinani Yes I did, it says that there is nothing more that I need to do more than adding the addon file to the other files.Ghiselin
Can you upload your PDF, if it's not very personalLanneret
Unfortunately it is personal. But the pdf files I am testing are not corrupted in any way, they are only pdf 1.5 and higher. Thats it.Ghiselin
S
5

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.

Sliest answered 6/7, 2017 at 13:12 Comment(1)
I note that PDFMerger loses the content as it treats the concatenated PDFs as image filesStoop

© 2022 - 2024 — McMap. All rights reserved.