我有一个这样的 iTextSharp 页脚模板方法:
public PdfTemplate footerTemplate(){
PdfTemplate footer = cb.CreateTemplate(500, 50);
footer.BeginText();
BaseFont bf2 = BaseFont.CreateFont(BaseFont.TIMES_ITALIC, "windows-1254", BaseFont.NOT_EMBEDDED);
footer.SetFontAndSize(bf2, 11);
footer.SetColorStroke(BaseColor.DARK_GRAY);
footer.SetColorFill(BaseColor.GRAY);
int al = -200;
int v = 45 - 15;
float widthoftext = 500.0f - bf2.GetWidthPoint(footerOneLine[0], 11);
footer.ShowTextAligned(al, footerOneLine[0], widthoftext, v, 0);
footer.EndText();
return footer;
}
footerTemplate() 得到这样的字符串:
footerOneLine.Add("<b>All this line is bold, and <u>this is bold and underlined</u></b>");
我还有另一种方法将字符串转换为 HTML。方法是:
private Paragraph CreateSimpleHtmlParagraph(String text) {
//Our return object
Paragraph p = new Paragraph();
//ParseToList requires a StreamReader instead of just text
using (StringReader sr = new StringReader(text)) {
//Parse and get a collection of elements
List<IElement> elements = iTextSharp.text.html.simpleparser.HTMLWorker.ParseToList(sr, null);
foreach (IElement e in elements) {
//Add those elements to the paragraph
p.Add(e);
}
}
//Return the paragraph
return p;
}
问题:我没有设法CreateSimpleHtmlParagraph
在上述代码中使用方法。footer.ShowTextAligned(al, footerOneLine[0], widthoftext, v, 0);
方法的数据类型是footer.ShowTextAligned(int, string, float, float, float);
你能帮我CreateSimpleHtmlParagraph
在上面的代码中如何使用方法吗?亲切的问候。