How to add height at the top and bottom of PDF page using PdfSharp?

700 views Asked by At

I have a pdf document whose height i want to increase at top and bottom so that certain text can be written on it.

So is it possible to add padding at top and bottom of the page using PdfSharp or any other free library which in turn will increase page height also?

Thanks in advance

Ramesh

1

There are 1 answers

0
RameshPasa On BEST ANSWER

I solved it as shown in following code snippet

// 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);
}