
public voID AddHTMLToContent(String HTMLText,PdfcontentByte contentBtye,IList<AcroFIElds.FIEldposition> pos) { Paragraph par = new Paragraph(); ColumnText c1 = new ColumnText(contentBtye); try { List<IElement> elements = HTMLWorker.ParsetoList(new StringReader(HTMLText),null); foreach (IElement element in elements) { par.Add(element); } c1.AddElement(par); c1.SetSimpleColumn(pos[0].position.left,pos[0].position.Bottom,pos[0].position.Right,pos[0].position.top); c1.Go(); //very important!!! } catch (Exception ex) { throw; } } 以下是对此函数的调用示例.
string HTMLText ="<b>Hello</b><br /><i>World</i>";IList<AcroFIElds.FIEldposition> pos = form.GetFIEldpositions("FIEld1");//FIEld1 is the name of the fIEld in the pdf Template you are trying to fill/overlayAddHTMLToContent(HTMLText,stamp.GetoverContent(pos[0].page),pos);//stamp is the pdfstamper in this example 我这样做的一件事是我的AcrofIEld确实有一个预定义的字体大小.由于此函数将ColumnText设置在字段的顶部,因此必须在函数中完成任何字体更改.以下是@R_455_6502@大小的示例:
public voID AddHTMLToContent(String HTMLText,null); foreach (IElement element in elements) { foreach (Chunk chunk in element.Chunks) { chunk.Font.Size = 14; } } par.Add(elements[0]); c1.AddElement(par); c1.SetSimpleColumn(pos[0].position.left,pos[0].position.top); c1.Go();//very important!!! } catch (Exception ex) { throw; } } 我希望这能为将来节省一些时间和精力.
总结以上是内存溢出为你收集整理的表单 – 使用iTextSharp使用HTML格式的文本填充PDF模板acrofield全部内容,希望文章能够帮你解决表单 – 使用iTextSharp使用HTML格式的文本填充PDF模板acrofield所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)