我正在使用ABCpdf 9.1 x64 .Net和Coldfusion来创建基于HTML内容的PDF。每个PDF文档都有一个不同的页眉和页脚,这些页面和页脚都是用一些Coldfusion代码生成的。页眉对于每页都略有不同的页面是相同的(因为它显示了页码)。这里是我的代码的主要部分:ABCpdf复制页眉和页脚
// 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));
}
正如你所看到的,AddImageHTML()
方法被调用的每一页,一次针对内容的2倍。所以,如果我有创建6页的内容,该方法被调用13次。这并不理想,因为这种方法花费了很多时间。
是否有一种更有效的方法来从HTML添加页眉和页脚?有一种方法AddImageCopy()
,但它不适用于由AddImageHtml()
创建的对象。
只是为了理解:那些getter和setter方法由Coldfusion创建以访问.Net属性。
这种方法,把标题是一样的。谢谢! – android