Hey guys.
I successfully created my single invoice document by following your sample. I also included page numbers, which is a nice feature itself.
But now I am trying to mass generate invoices, which means I want to generate each single invoice as before, and add it to a "container" document which includes all invoices.
This works fine:
Code:
Document document = new Document();
OrderCollection orders = ShopServiceManager.Orders().GetOrdersByCustomer(34);
foreach (var order in orders)
{
BL.Documents.Invoice invoice = new BL.Documents.Invoice();
invoice.DocumentCreator = new InvoiceDocument();
invoice.Order = order;
invoice.Print(false);
document.Add(invoice.Document.LastSection.Clone());
}
PdfDocumentRenderer pdfRenderer = new PdfDocumentRenderer(true);
pdfRenderer.Document = document;
pdfRenderer.RenderDocument();
The print method sets the property Document of the invoice object to the internally new generated MigraDoc Document. By adding the LastSection I can add the single document to the container doc and print this container document at the and of the game.
This all works. The problem: the page numbers are counted over all single invoice documents within the container doc. For example, if I am printing 6 invoices which are all containing one single page, I should get a result like 6 times "Page 1/1". Instead of that I get "Page 1/6", "Page 2/6" and so on - because the used AddNumPagesField() seems to be counted over all documents (sections).
I was trying to render each single invoice within the loop and add the final rendered result to the container document, but with no success.
I would be very glad if anyone could assist.
Thanks in advance!