【问题标题】:How To wrap Text while using PdfContentByte in itextsharp如何在 itextsharp 中使用 PdfContentByte 时换行文本
【发布时间】:2012-08-18 09:12:43
【问题描述】:

我使用 PdfContentByte 在 pdf 中显示文本,因为我还使用 SetTextMatrix mathod 来定位该文本,现在当我的文本很大时它不会显示在 pdf 中显示我可以包装文本显示我可以在下面看到它是我的代码

PdfContentByte cb = myPDFWriter.DirectContent;
cb.BeginText();
BaseFont bf_qty123 = BaseFont.CreateFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, false);
cb.SetFontAndSize(bf_qty123, 10f);
cb.SetTextMatrix(422,100);
cb.ShowText("longstring");
cb.EndText();

【问题讨论】:

    标签: itextsharp


    【解决方案1】:

    像这样使用列:

    Dim p As Phrase = New Phrase("your txt", FontFactory.GetFont(BaseFont.HELVETICA, BaseFont.CP1250, True, fsize)) 
    Dim ct As New ColumnText(cb) 
    ct.SetSimpleColumn(p, x, y, ux, uy, 10, Element.ALIGN_LEFT)
    ct.Go()
    

    并固定宽度高度 bloc ux, uy

    另请参阅:

    How to position and wrap long text?

    【讨论】:

    • 不知道为什么这被否决了,这与我在项目中用于包装文本的代码几乎相同。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-30
    • 2018-03-03
    • 2011-07-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多