evopdf – Evo Pdf – HTML中的页码编号

evopdf – Evo Pdf – HTML中的页码编号,第1张

概述我知道可以使用C#API在页眉/页脚中呈现“Page X of Y”,如下所示: //write the page numberTextElement footerText = new TextElement(0, pdfConverter.PdfFooterOptions.FooterHeight - 15, "This is page &p; of &P; ", new Syste 我知道可以使用C#API在页眉/页脚中呈现“Page X of Y”,如下所示:

//write the page numberTextElement footerText = new TextElement(0,pdfconverter.pdfFooterOptions.FooterHeight - 15,"This is page &p; of &P;  ",new System.Drawing.Font(new System.Drawing.FontFamily("Times New Roman"),10,system.drawing.graphicsUnit.Point));footerText.EmbedSysFont = true;footerText.TextAlign = HorizontalTextAlign.Right;pdfconverter.pdfFooterOptions.AddElement(footerText);

..但我宁愿使用以下方法直接在HTML中定位和设置样式:

HTMLTopdfElement footerHTML = new HTMLTopdfElement(pdfOptions.documentFooterHTMLString,pdfOptions.BaseUrl); footerHTML.FitHeight = true; pdfconverter.pdfFooterOptions.AddElement(footerHTML);

其中pdfOptions.documentFooterHTMLString看起来像这样:

<div >    <span >This is page &p; of &P;</span></div>

这是可能的吗?如果我试试这个,我就得到:这是页面& p; & P;在页脚中呈现.

解决方法 我简单地对此挣扎.为了通过搜索找到它的其他人,诀窍是当你添加HTML元素时,它必须是HTMLTopdfVariableElement而不是HTMLTopdfElement.

HTMLTopdfVariableElement footerHTML = new    HTMLTopdfVariableElement(pdfOptions.documentFooterHTMLString,pdfOptions.BaseUrl);footerHTML.FitHeight = true;pdfconverter.pdfFooterOptions.AddElement(footerHTML);
总结

以上是内存溢出为你收集整理的evopdf – Evo Pdf – HTML中的页码编号全部内容,希望文章能够帮你解决evopdf – Evo Pdf – HTML中的页码编号所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1042992.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-24
下一篇2022-05-24

发表评论

登录后才能评论

评论列表(0条)

    保存