FPDF error: Unable to find xref table

Sometimes you may face a problem with FPDF and FPDI when trying to concatenate some PDF files. The only output I got was 'FPDF error: Unable to find xref table.' When I did a search on this error message, I wasn't able to extract the answer from it. After some searching, the problem was located.

One of the PDFs which should be merged was originally created from Word by a PDF creator which placed its signature in the properties of the PDF document. After removing this signature (in this case opening the PDF with Adobe Illustrator and saving it again) the problem was solved.

Compression and stream

The FPDF / FPDI classes use the input stream of the PDF file to create the concatenated PDF. Setasign remarks that the stream is only used (and altered) in the free version. The paid version should not give such errors. As I've experimented with the free version, I'll treat that one here.

Because of compression, some applications might leave out or mess up the xref property. Although this results in a PDF file which can be opened in a PDF reader, the stream is not according to the 'standards'. In such a case the document markup is 'lost' and applications / scripts using this property cannot handle these files any more.

PDF merging code example

To show how PDF files can be merged by using FPDF and FPDI I've compiled a little example which can be downloaded here. The archive consists of FPDF version 1.6, FPDI version 1.3.1, FPDI_TPL and two sample PDF files which were created with Microsoft Word 2007. The executing script is concat.php. Run this script to concatenate the two sample PDF files together in a new PDF file.

Possible solutions

A paid version of FPDI might be an option, but  you have to buy a licence to get PDF's running,  And the PDF is the power of our component. Let's take a look at other solution.

Opening the file and saving it again with a better pdf creator might fix the problem as it reformats the stream which is saved. The problems mostly occurs when you are using PDF creators for Word Documents for example. (When creating PDF Files from Photoshop / Indesign or Illustrator you probably won't face this issue)

Final remarks

When you're creating the source PDF files yourself, watch out which pdf creator you use. Although the visual result might be the same, the stream might not be.

Why Choose Us?

Latest Joomla! & PHP Versions!

We're always developing our components in the latest Joomla! and PHP environments! No need to be scared to run in troubles when your hosting company is updating their servers. We have probable tested it already ;)

100% Open Source

Our code is fully Open Source, so you can make changes to the code as much as you like! Making changes to the code? We can advise, but don't support your custom code. Using overides is the best thing to do!

Responsive Design

All extensions are as responsive as possible built on the shipped Joomla Bootstrap 2.x.x Library! We will soon make all our products compatible with Boostrap 3 to make sure it works on all Bootstrap versions.

Easy updating by the Joomla Updater

All components are being shipped with Joomla Update support, this means you don't have to upgrade manually anymore! The only thing you need to do is making sure you have entered a valid Download Key!

Quality Guaranteed

All our components are fully based on the Joomla API, this gives us flexibility so we can guarantee the quality of our products. When Joomla moves on, we're also moving on!

Service & Support

All our components are fully based on the Joomla API, this gives us flexibility so we can guarantee the quality of our products. When Joomla moves on, we're also moving on!