使用Norwegian生成的Itextsharp pdf在一些文字

时间:2016-04-14 15:00:22

标签: c# itextsharp multilingual

English language in PDF

Norwegian language in PDF

使用Itextsharp使用挪威语生成的pdf在一些文本后添加了底部填充 无法减少填充,因为没有。由于文本数量的不同,不能有固定的高度。无法获得行/单元格的高度,因为它只能在渲染后才能实现

编辑:它只发生在下拉列表的顶部而不是任何其他答案选项。

请帮助。

    private static void AddTextCell(PdfPTable table, string text, int rowspan = 1, int colspan = 1, float border = 0f, float padding = 0f)
    {
        Font arial = FontFactory.GetFont("Arial", 12, BaseColor.BLACK);

        PdfPCell cell = new PdfPCell(new Phrase(text, arial))
        {
            Rowspan = rowspan,
            Colspan = colspan,
            BorderWidth = 0f,
            PaddingTop = padding,
            PaddingBottom = padding,
            HorizontalAlignment = PdfPCell.ALIGN_LEFT,
            VerticalAlignment = PdfPCell.ALIGN_MIDDLE
        };

        if (colspan > 1)
        {
             cell.BackgroundColor = BaseColor.CYAN;
        }
        else
        {
            cell.BackgroundColor = BaseColor.GREEN;
        }

        table.AddCell(cell);
    }

1 个答案:

答案 0 :(得分:1)

源挪威语文本中有空白字符。

我使用Regex.Replace

删除了它们
  

string textWithoutWhiteSpaceCharacters = Regex.Replace(textWithWhiteSpaceCharacters,“[\ n \ r \ t]”,“”);