FPDF error: This document (testcopy.pdf) probably uses a compression technique which is not supported by the free parser shipped with FPDI

40,107

Solution 1

Yes, Exactly the FPDF library supports only PDF version 1.4 & lesser. So to over come from this issue use GhostScript. This script helps to change the PDF versions dynamically.

(1) Download the Ghostscript here.

(2) Install the Ghostscript and define the environment variable PATH.

(3) Then, use the below php code to change the PDF version.

shell_exec( "gswin32 -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=".$new_pdf." ".$old_pdf.""); 

(4) Now we get PDF with version 1.4 as output, then continue with FPDF.

Enjoy!

Solution 2

I had the same issue that PDFMerger does not work with certain PDF. It seems that Adobe keep updating compression way of pdf extension.

I found solution with Chrome.

1. Open the PDF file(which does not work with PDFMerger) with Chrome
2. Right Click and Print
3. Change destination as [Save as PDF]
4. This exported PDF file is compatible with PDFMerger

Solution 3

The file needs to be PDF 1.4 (Acrobat 5) or lower. If you have Adobe Acrobat Pro you can change this with Document->Decrease File Size.

Solution 4

Looking through the answers so far, I wasn't able to resolve the issue. Here's why and you may have the same issue so this answer would be invaluable to you too.

I did not have access to acrobat, so I couldn't downgrade the version of the original PDF. I wasn't in a position to purchase the newer version of the library which has upgraded encryption.

In the end I used an online PDF converter to downgrade my PDF file to version 5 (1.4)

If you are not able to find one, here's a link for completeness.

https://docupub.com/pdfconvert/

(bear in mind that the contents of a link may change)

Solution 5

Here is my answer from another topic:

"It can be overcome by re-saving the template and change compression type. In Adobe Acrobat Pro go to File->Save As->Optimised PDF-> Popup left list - Clean Up, Object Compression Options -> Change to "Compress document structure" -> OK to save"

Ref. Editing password protected pdfs with fpdi

Share:
40,107
Admin
Author by

Admin

Updated on September 10, 2021

Comments

  • Admin
    Admin almost 3 years

    I am running the following code and giving me this error : FPDF error: This document (testcopy.pdf) probably uses a compression technique which is not supported by the free parser shipped with FPDI. I used another pdf named test.pdf and that works fine but it is giving me error in testcopy.pdf.

    I think this is parser problem. Anyone know any other parser that can be used with fpdf to avoid this error?

    My code:

    require('fpdf17/fpdf.php'); 
    require('fpdf17/fpdi.php'); 
    // initiate FPDI 
    $pdf = new FPDI(); 
    while (ob_get_level())
    ob_end_clean();
    header("Content-Encoding: None", true);
    // set the sourcefile 
    $pagecount = $pdf->setSourceFile('testcopy.pdf');
    

    I want to split pdf in two pdfs and want to attach both pdfs in file attachments field.How to save pdf to server. Can it be possible with fpdf?

  • Admin
    Admin almost 12 years
    i know that i was asking about another parser that can be used with fpdf that support all type version.
  • Laurie Clark
    Laurie Clark over 8 years
    Thanks for this ! I had to change gswin32 to gs for this to work
  • Marsha
    Marsha over 7 years
    What do you mean by "define the environment variable PATH"? Thanks in advance.
  • Kevin Florenz Daus
    Kevin Florenz Daus over 7 years
    @Marsha It means you should add the path of ghostscript executable to the PATH variable on your Windows OS. search this keyword and it will tell you how. "adding path to windows"
  • nbonniot
    nbonniot over 6 years
    This should be marked as answer this is so far the very best shot I saw.
  • Matt
    Matt about 6 years
    I used to use Ghostscript to do this but this does indeed work, way more convenient. Thanks!
  • HerrimanCoder
    HerrimanCoder over 5 years
    This should be the accepted answer. By far the easiest approach.
  • QuantumBlack
    QuantumBlack over 4 years
    Chrome seems to do the same thing, open in Google Chrome and print as PDF
  • Rakibul Haq
    Rakibul Haq over 4 years
    this link shows how it is done using a full practical example, it may help someone: infoconic.com/blog/…
  • skywind
    skywind over 2 years
    Thank you! You save my time! Best answer))
  • Brady Edgar
    Brady Edgar over 2 years
    Worked for me, thanks so much!