Uploading PDF

Forum for .PHP developers using the E-conomic API.
Exchange your ideas, tip and tricks using the API.
Best Practices

Uploading PDF

Postby rhlie » Fri Aug 12, 2011 12:37 pm

Hi,

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!
-
rhlie
 
Posts: 1
Joined: Fri Aug 12, 2011 12:32 pm

Re: Uploading PDF

Postby Christian Estrup » Sat Aug 13, 2011 7:33 am

Hi,

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,
Christian Estrup
Chief Architect

Image
Online accounting
User avatar
Christian Estrup
 
Posts: 245
Joined: Tue Jun 09, 2009 6:37 pm

Re: Uploading PDF

Postby sitetech » Wed Apr 18, 2012 9:54 am

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:

Code: Select all
// 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
-
sitetech
 
Posts: 2
Joined: Wed Apr 18, 2012 9:21 am

Re: Uploading PDF

Postby Christian Estrup » Wed Apr 18, 2012 9:58 am

Hi,

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


Regards,
Christian Estrup
Chief Architect

Image
Online accounting
User avatar
Christian Estrup
 
Posts: 245
Joined: Tue Jun 09, 2009 6:37 pm

Re: Uploading PDF

Postby sitetech » Wed Apr 18, 2012 2:08 pm

Sure...

The PDF details is:

PDF Producent: TDPDF 5.9.156 (http://tcpdf.org)
PDF Verson: 1.7 (Acrobat 8.x)
-
sitetech
 
Posts: 2
Joined: Wed Apr 18, 2012 9:21 am


Return to PHP



cron