Similarly to the InvoiceAPI.PostInvoice method, you can also call InvoiceAPI.PostInvoicePDF in order to get the invoice PDF if you wish to save it or process it in any other manner.
Below is a code snippet showing how to use the method. In this example we are invoicing an order with order number 559. Just like the PostInvoice, the InvoiceNumber parameter should be 0 if you wish to have auto increment the invoice number.
// Instantiate InvoiceAPI
var iapi = new InvoiceAPI(crud);
// Get a specific order and acquire its lines
var order = new DebtorOrderClient { OrderNumber = 559 };
await crud.Read(order);
var lines = await crud.Query<DebtorOrderLineClient>(order);
// Post the Invoice and get the PDF
var invoiceResult = await iapi.PostInvoicePDF(order, lines, DateTime.Now, 0, false, CompanyLayoutType.Invoice);
var data = invoiceResult.pdf;
System.IO.File.WriteAllBytes(@"C:\Uniconta\MyTestPDF.pdf", data);