Rank: Newbie Groups: Member
Joined: 5/29/2013 Posts: 1
|
Hi,
here is my coding problem(using c#)
...... HtmlToPdf.Options.AfterRenderPage = new EO.Pdf.PdfPageEventHandler(On_AfterRenderPage);
HtmlToPdf.ConvertHtml(htmlCode,pdfPath);
.......
private void On_AfterRenderPage(object sender, EO.Pdf.PdfPageEventArgs e) { int total page count=???; AcmBlock footer = new AcmBlock(new AcmText(string.Format("{0}/{1}", e.Page.Index + 1,total page count))); }
before a pdf document is created, EO renders page first, and I could not get the total page count number. I need a page total count number to mark as
1/3 2/3 3/3 total page count is 3
and how can I get the number "3" when the real pdf file is not created yet?
thanks!!
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi, You can not. You do not have to use AfterRenderPage event. You can just add your footer after the ConvertHtml call. Your code can be something like this:
Code: C#
//Convert the HTML. Note you are converting to a PdfDocument
//object, not a physical file here (the second argument of
//ConvertHtml is a PdfDocument object)
PdfDocument doc = new PdfDocument();
HtmlToPdf.ConvertHtml(htmlCode, doc);
//Use a loop to add footer
for (int i = 0; i < doc.Pages.Count; i++)
{
//Now add footer to doc.Pages[i]
.....
}
//Save the PDF file
doc.Save(pdfPath);
Hope this helps. Thanks!
|