首页 文章

如何使用PdfSharp在PDF页面的顶部和底部添加高度?

提问于
浏览
1

我有一个pdf文档,其高度我想在顶部和底部增加,以便可以在其上写入某些文本 .

那么可以使用PdfSharp或任何其他免费库在页面的顶部和底部添加填充,这反过来也会增加页面高度吗?

提前致谢

拉梅什

1 回答

  • 0

    我解决了它,如下面的代码片段所示

    // Open the document 
    PdfDocument inputDocument = PdfReader.Open(@"D:\test.pdf", PdfDocumentOpenMode.Modify);
    
    // Iterate pages
    foreach (PdfPage page in inputDocument.Pages)
    {
        // Add height at top of the page
        page.Height += 100;
    
        // Add height at bottom of the page
        XRect rect= new XRect(0, -100, page.Width, page.Height + 100);
        page.MediaBox = new PdfRectangle(rect);
    }
    

相关问题