API Forum

This forum is in read-only mode.
Please refer to our API support in case you have any questions.
We can be reached at api@e-conomic.com
e-conomic API developer forum

Uploading PDF


I am trying to use CashBook_RegisterPdfVoucher to add a pdf file. When i Upload it I get this error message:
Economic.Api.Exceptions.ValidationException(E04000): File is not valid PDF. {id=1703039636}

I have verified that the base64 encoded file is valid (when echoing this back out using base64_decode it loads in adobe pdf)

the line i run to to this is
            $uploadresult = $client-CashBook_RegisterPdfVoucher(array(data=$encodedImage, voucherNumber=20, entryDate=date(Y-m-d). T00:00:00));

Any help would be much appreciated!
created Aug 12, 2011 by rhlie
0% Accept Rate
Q 1 A 0 C 0

4 Answers


Please try sending the file to our API tech support at api@e-conomic.com.

We'll then check whether it's a 'PDF file' issue - if not, we'll be sure it's related to the encoding.

Best regards,
answered Aug 13, 2011 by Christian Estrup
I have the same problem, but found out that PDF's I created with a software on my laptop worked just fine.

PDF invoices created with TCPDF or PFPDF (PHP PDF generator), will not work since they are not accepted as PDF's with correct headers (I guess), and the error: Economic.Api.Exceptions.ValidationException(E04000): File is not valid PDF. {id=XXX} is returned.

Note this issue is when attaching a PDF to a voucherNumber with following code:

// testet with
$pdf = $path;
$encoded = file_get_contents($pdf);
// and
//$encoded = base64_encode($pdf);

$client-CashBook_RegisterPdfVoucher(array(data=$encoded, voucherNumber=$voucherNumber, entryDate=$voucherDate));

Is it something the E-conomic team can check up on? I have tested and found the bug with Joomla! 2.5 and Virtuemart 2.0.X. The bug is not in the Joomla! og Virtuemart itself, but e-conomic.

If I download the generated PDF and save it as a copy on my laptop, and then upload it via API, the error is still shown. I imagine e-conomic doesn't approve generated PDF's via API (or maybe old-version-PDF's) at the moment?

It is odd, since the generated PDF is accepted with no problem when e-mailing it as attachement to the e-conomicmail given for import. :S

Best regards Lasse
answered Apr 18, 2012 by sitetech
reshown Jul 29, 2015 by olej

Could you try opening the PDF in some reader, and then check the PDF file format version you're using?

answered Apr 18, 2012 by Christian Estrup

The PDF details is:

PDF Producent:  TDPDF 5.9.156 (http://tcpdf.org)
PDF Verson:       1.7 (Acrobat 8.x)
answered Apr 18, 2012 by sitetech
reshown Jul 29, 2015 by olej
Visma e-conomic A/S