ExpertPDF-如何根据HTML中的内容了解页码

ExpertPDF-如何根据HTML中的内容了解页码,pdf,pdf-generation,Pdf,Pdf Generation,现在我必须以PDF格式打印此模板,在打印过程中,我必须添加索引页,该页实际上引用了带有标题的页码。意味着打印输出应该是这样的 Suppose I have a HTML that have some heading & text like: Heading 1 text...... Heading 2 text..... Heading 3 text..... 所以在这里我想知道,如何知道基于HTML文本的页码,比如标题1属于哪个页码&对于其他页码 Heading 1 .....

现在我必须以PDF格式打印此模板,在打印过程中,我必须添加索引页,该页实际上引用了带有标题的页码。意味着打印输出应该是这样的

Suppose I have a HTML that have some heading & text like:

Heading 1
text......

Heading 2
text.....

Heading 3
text.....
所以在这里我想知道,如何知道基于HTML文本的页码,比如标题1属于哪个页码&对于其他页码

Heading 1 ....... 1 [page number]
Heading 2 ....... 2 
Heading 3 ....... 3 

Heading 1
text......

Heading 2
text.....

Heading 3
text.....

pdfConverter.PdfFooterOptions.PageNumberTextFontSize=10; pdfConverter.PdfFooterOptions.ShowPageNumber=true

它在该方法的主体内完成:-

Any suggestion or idea really appreciated.
有关更多详细信息,请参阅本页
pdfConverter.PdfFooterOptions.PageNumberTextFontSize=10; pdfConverter.PdfFooterOptions.ShowPageNumber=true

它在该方法的主体内完成:-

Any suggestion or idea really appreciated.
有关更多详细信息,请参阅本页
这实际上是一个相当棘手的问题,ExpertPDF必须提供特定的功能才能解决


我的解决方案(不是expertpdf)是首先计算PDF的布局,获取每个页面的索引中要使用的文本,然后计算索引页面的布局。然后我可以对页面(包括索引页面)进行编号,然后更新索引中的页码。。这是处理跨越多个页面的模板页面、覆盖多行的索引文本以及跨越多个页面的索引的唯一方法。

这实际上是一个相当棘手的问题,ExpertPDF必须提供特定的功能才能实现

我的解决方案(不是expertpdf)是首先计算PDF的布局,获取每个页面的索引中要使用的文本,然后计算索引页面的布局。然后我可以对页面(包括索引页面)进行编号,然后更新索引中的页码。。这是处理跨多个页面的模板页面、换行多行的索引文本以及跨多个页面的索引的唯一方法。

创建TextElement

private void AddFooter(PdfConverter pdfConverter)
{
string thisPageURL = HttpContext.Current.Request.Url.AbsoluteUri;
string headerAndFooterHtmlUrl = thisPageURL.Substring(0, thisPageURL.LastIndexOf('/')) + "/HeaderAndFooterHtml.htm";

//enable footer
pdfConverter.PdfDocumentOptions.ShowFooter = true;
// set the footer height in points
pdfConverter.PdfFooterOptions.FooterHeight = 60;
//write the page number
pdfConverter.PdfFooterOptions.TextArea = new TextArea(0, 30, "This is page &p; of &P; ",
new System.Drawing.Font(new System.Drawing.FontFamily("Times New Roman"), 10, System.Drawing.GraphicsUnit.Point));
pdfConverter.PdfFooterOptions.TextArea.EmbedTextFont = true;
pdfConverter.PdfFooterOptions.TextArea.TextAlign = HorizontalTextAlign.Right;
// set the footer HTML area
pdfConverter.PdfFooterOptions.HtmlToPdfArea = new HtmlToPdfArea(headerAndFooterHtmlUrl);
pdfConverter.PdfFooterOptions.HtmlToPdfArea.EmbedFonts = cbEmbedFonts.Checked;
}
库将自动替换&p;令牌。

创建一个TextElement

private void AddFooter(PdfConverter pdfConverter)
{
string thisPageURL = HttpContext.Current.Request.Url.AbsoluteUri;
string headerAndFooterHtmlUrl = thisPageURL.Substring(0, thisPageURL.LastIndexOf('/')) + "/HeaderAndFooterHtml.htm";

//enable footer
pdfConverter.PdfDocumentOptions.ShowFooter = true;
// set the footer height in points
pdfConverter.PdfFooterOptions.FooterHeight = 60;
//write the page number
pdfConverter.PdfFooterOptions.TextArea = new TextArea(0, 30, "This is page &p; of &P; ",
new System.Drawing.Font(new System.Drawing.FontFamily("Times New Roman"), 10, System.Drawing.GraphicsUnit.Point));
pdfConverter.PdfFooterOptions.TextArea.EmbedTextFont = true;
pdfConverter.PdfFooterOptions.TextArea.TextAlign = HorizontalTextAlign.Right;
// set the footer HTML area
pdfConverter.PdfFooterOptions.HtmlToPdfArea = new HtmlToPdfArea(headerAndFooterHtmlUrl);
pdfConverter.PdfFooterOptions.HtmlToPdfArea.EmbedFonts = cbEmbedFonts.Checked;
}

库将自动替换&p;标记。

不,我不想在页脚中插入页码,我想根据HTML中的一些文本来知道页码。就像在HTML中一样,我有文本ABC&我想知道这个ABC在打印时属于哪个页码。嗨,试试这个链接否,我不想在页脚中插入页码,我想知道基于HTML中某些文本的页码。就像在HTML中一样,我有文本ABC&我想知道这个ABC在打印时属于哪个页码。嗨,试试这个链接