Hi Tommy, more questions for you…
I’m trying to load an invoice template from an XML file and then use the same template to generate many invoices. Here the C# code used :
string templateFile = System.Web.HttpRuntime.AppDomainAppPath + “\Settings\AsposeInvoice.xml”; mPdfDocument.BindXML(templateFile, null); Aspose.Pdf.Section section = mPdfDocument.Sections[“invoice1”]; // Create PDF Template CreateTemplate(section); Aspose.Pdf.Section templateSection = section.CompleteClone() as Aspose.Pdf.Section; bool firstInvoice = true; Model.Client client; for (int i=0; i<mClientList.Count; ++i) { client = mClientList[ i ] as Model.Client; if (firstInvoice == true) { section = mPdfDocument.Sections[“invoice1”]; firstInvoice = false; } else { section = templateSection.CompleteClone() as Aspose.Pdf.Section; section.ID = “invoice” + (i+1); mPdfDocument.Sections.Add(section); } GeneratePage(client, section); } |
CreateTemplate() fills the text common to all invoices (such as date, legal notice, return address, etc.)
GeneratePage() fills the client-dependant data (such as name, balance, address, etc.)
The problem is that the first invoice is OK, but all the following seem to lose the custom positioning used (ParagraphRelative mostly) when I make a CompleteClone() of the templateSection. It seems to revert to AutoPositioning. As you can imagine, this is a problem for me.
Is there a way to use the same “virgin” template XML for all sections of the Pdf, instead of creating the first section and then copying it. Kind of like what you have in ceTe.DynamicPdf?
Can you confirm this ?
Thanks,
Dominic.