首页 > 解决方案 > itext7 覆盖长字符串值

问题描述

我有以下代码:

    void Main()
   {
       var writer = new PdfWriter(@"c:\temp\Overwrite.pdf");
            var pdf = new PdfDocument(writer);
            var document = new Document(pdf);
    
        var p = new Paragraph($"Feature: 4.2 - Release Selection and a very big welcome to the Community this has been a very good project indeed, I sure do like it. How about yourself, very big welcome to the Community, this has been a very good project indeed, I do like it. Selection and a very big welcome to the Community this has been a very good project indeed, I sure do like it. ").SetKeepWithNext(true)
                    .SetMarginTop(10)
                    .SetMarginBottom(10)
                    .SetFixedLeading(0f);
    
        document.Add(p);
        
        document.Close();
    }

但输出结果如下: 在此处输入图像描述 我怎样才能让文本换行到下一行而不覆盖自身?

标签: c#itext7

解决方案


我不确定这条线在做什么,但它会导致问题,如果你像我在这里所做的那样评论它,你的文字就可以了。

var p =
        new Paragraph(s)
        .SetKeepWithNext(true)
        .SetMarginTop(10)
        .SetMarginBottom(10);
        //SetFixedLeading(0f);

推荐阅读