首个内容的上边距不显示

时间:2019-11-13 03:47:18

标签: itext

我正在使用带有C#的itextsharp创建pdf。但是,每当我添加文本或图像作为pdf第一页的第一内容时,就不会显示边距。这里仅显示页边距。该怎么解决?

这是我的代码。

string textFont = "c:\\windows\\fonts\\" + fontName;

        pdfFont = FontFactory.GetFont(textFont, BaseFont.CP1252, BaseFont.EMBEDDED, fontSize, fontStyle, color);


        marginTop = iTextSharp.text.Utilities.MillimetersToPoints(marginTop);
        marginLeft = iTextSharp.text.Utilities.MillimetersToPoints(marginLeft);
        marginRight = iTextSharp.text.Utilities.MillimetersToPoints(marginRight);
        Paragraph paragraph = new Paragraph(pdfText, pdfFont);
        //paragraph.SetLeading(textLeading, 0);
        paragraph.SetLeading(0, lineSpace);
        paragraph.Alignment = textAlignment;
        paragraph.SpacingBefore = marginTop;
        paragraph.IndentationLeft = marginLeft;
        paragraph.IndentationRight = marginRight;
        document.Add(paragraph);

0 个答案:

没有答案