Search code examples
tcpdffpdi

FPDI setSourceFile throws exception


$pagecount = $pdf->setSourceFile($pdffile);

The above line is throwing the exception "This document ([file path]) probably uses a compression technique which is not supported by the free parser shipped with FPDI."

This is happening despite:

  • the file existing (I logged $pdffile to ensure the path was correct and downloaded the pdf from that location to ensure validtiy)
  • the file path being absolute (the path starts at the root of the server all the way to the file's location)
  • the pdf version being 1.3
  • the folder permissions for this file's directory and file being 777
  • it working fine within the last few days (I'm assuming permissions got thrown off with some deployment, but I can find where or why)

Any thoughts? thanks.

FPDI: 1.6.1 TCPDF: 6.2.13


Solution

  • This ended up being an issue with either the version or some corruption of all PDFs. It's still a mystery as we have hundreds of PDFs that were working before, then none of them worked. I downloaded 20 or so to verify versions and all were displaying PDF 1.4 or 1.3 when opened in Acrobat. They were also able to open with no error messages in any reader.

    After hours of this, I finally just started from the ground up and walked through every piece again assuming nothing was working. When I got to the PDF, I ran it through an online converter and re-uploaded the file and the PDF worked. I tried many more PDFs and they all worked. So we installed GhostScript and started running all PDFs through GhostScript on the fly. All PDFs are working now.

    Thus my only conclusion is that somewhere somehow in moving files around, all the PDFs in that one directory got corrupted.