I'm using ABCpdf 9.1 x64 .Net with Coldfusion to create PDF's based on HTML content. Each PDF document has a different header and footer which are generated as HTML with some Coldfusion code. The header is identical for every page where the footer is slightly different for every page (because it shows the page number). Here's the main part of my code:
// add content
theDoc.Get_Rect().Set_String("67 80 573 742");
theContentID = theDoc.AddImageHTML(pdfContent);
while (true) {
if (!theDoc.Chainable(theContentID)) {
break;
}
theDoc.Set_Page(theDoc.AddPage());
theContentID = theDoc.AddImageToChain(theContentID);
}
// add header & footer on each page
for (i=1; i <= theDoc.Get_PageCount(); i++) {
// set page
theDoc.Set_PageNumber(i);
// HEADER
theDoc.Get_Rect().Set_String("67 755 573 809");
theDoc.AddImageHTML(headerContent);
// FOOTER
theDoc.Get_Rect().Set_String("67 0 573 65");
theDoc.AddImageHTML(replace(footerContent, "[page]", i));
}
As you can see, the AddImageHTML()
method gets called 2 times for every page and once for the content. So if I have content which creates 6 pages, the method gets called 13 times. This isn't ideal because the method consums a lot of time.
Is there a more efficient way to add a header and footer from HTML? There's a method AddImageCopy()
but it doesn't work with objects created by AddImageHtml()
.
Just for understandig: Those getter and setter methods are created by Coldfusion to access .Net properties.