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

How to get invoice PDF

0
Hi

I'm trying to create a new invoice, and all is fine... but on the returned PDF there is a watermark saying that it is a kladde (Draft). How do I remove this?

My code is:

$myProduct = $client-Product_FindByNumber(array('number' = $product_number))-Product_FindByNumberResult;
               
$newCurrentInvoiceHandle = $client-CurrentInvoice_Create(array('debtorHandle' = $myDebtor))-CurrentInvoice_CreateResult;
                                           
$newCurrentInvoiceLineHandle = $client-CurrentInvoiceLine_Create(array('invoiceHandle' = $newCurrentInvoiceHandle))-CurrentInvoiceLine_CreateResult;
                                                          
$client-CurrentInvoiceLine_SetDescription(array('currentInvoiceLineHandle' = $newCurrentInvoiceLineHandle, 'value' = utf8_encode($description)));
$client-CurrentInvoiceLine_SetProduct(array('currentInvoiceLineHandle' = $newCurrentInvoiceLineHandle, 'valueHandle'= $myProduct));
$client-CurrentInvoiceLine_SetUnitNetPrice(array('currentInvoiceLineHandle' = $newCurrentInvoiceLineHandle, 'value' = $price));
$client-CurrentInvoiceLine_SetQuantity(array('currentInvoiceLineHandle' = $newCurrentInvoiceLineHandle, 'value' = 1));


$pdf = $client-CurrentInvoice_GetPdf(array('currentInvoiceHandle'=$newCurrentInvoiceHandle))-CurrentInvoice_GetPdfResult;
$result = $client-CurrentInvoice_Book(array('currentInvoiceHandle' = $newCurrentInvoiceHandle))-CurrentInvoice_BookResult-Number;




Hope you can help my.
created Jul 25, 2011 by wsy
0% Accept Rate
Q 1 A 2 C 0

4 Answers

0
Hi,

As long as the invoice hasn't been booked, it IS a draft.

If you book the invoice (CurrentInvoice.Book()), you can get a non-watermarked PDF from the resulting Invoice object.


Best regards,
answered Jul 26, 2011 by Christian Estrup
0
I tried switch the 2 last lines so the invoice is booked before I try to get the PDF... but in this case it just give me an error!

Can you post to lines of code that will do the trick?

/Henrik
answered Jul 26, 2011 by wsy
0
Hi,

I'm no PHP expert - but in .NET, you'd do something like this:

// objCurrentInvoice is our current invoice
IInvoice objInvoice = objCurrentInvoice.Book();
byte[] pdfData = objInvoice.GetPdf();


Best regards,
answered Jul 27, 2011 by Christian Estrup
0
Ok i got it now, thank you.

If others have the same question the solution was:

$result = $client-CurrentInvoice_Book(array('currentInvoiceHandle' = $newCurrentInvoiceHandle))-CurrentInvoice_BookResult;
$pdf = $client-Invoice_GetPdf(array('invoiceHandle'=$result))-Invoice_GetPdfResult;
$result = $result-Number;
answered Jul 27, 2011 by wsy
hi..

How can i get it as PDF file. I m getting it as raw data. I m using PHP. How to convert that data as PDF ?
My best guess would be that you set the correct header and then echo the raw data.

header('Content-type: application/pdf');
header('Content-Disposition: attachment; filename="e-conomic-invoice.pdf"');
echo $pdf;
Visma e-conomic A/S
...