小编Lil*_*ian的帖子

如何使用itextsharp删除pdf文档的默认上边距?

我试图让我的pdf文档从(0,0)开始,但是看起来文档对象有一个默认的上边距,我不能设置为0.有没有办法做到这一点?

我的代码如下所示

        using (MemoryStream memoria = new MemoryStream())
        {
            Document pdf = new Document(new Rectangle(288, 144));

            try
            {
                PdfWriter writer = PdfWriter.GetInstance(pdf, memoria);

                pdf.Open();
                pdf.SetMargins(0, 0, 0, 0);

                PdfPTable tPrincipal = new PdfPTable(2);            
                tPrincipal .WidthPercentage = 100;           
                tPrincipal .DefaultCell.Border = 0;
                tPrincipal .TotalWidth = 288f;
                tPrincipal .LockedWidth = true;
Run Code Online (Sandbox Code Playgroud)

....

我无法将上边距设置为0.它只是不关心我的设置为(0,0,0,0)并留下上边距(约50f).

margin itextsharp

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

itextsharp ×1

margin ×1