Add Margin To Existing PDF in C# using Aspose.PDF for .NET

How do I add margin a pdf that I’ve loaded from disc or an arbitrary source. If you use


Pdf p = new Pdf(stream)

and make modifications, the call to

p.Save(strea2)

will throw “You’re in direct to file mode. Please use Close instead of Save”.

In the case of a newly generated pdf like

Pdf p = new Pdf();

// manipulate new pdf

that’ll work fine since you wouldn’t be in direct to file mode.

I’m sure there’s some utility you guys have like PdfFileStamp or PdfFileMend that can do the job for me. I’ve yet to find it though. These types of classes all server individual purposes, but none seam to handle scenarios related to margin. Your help would be greatly appreciated. Also do you guys have support for rendering HTML as a header? Plain text will obviously work, but we have a requirement where the header should be formatted as a table. Thanks.

Hi Charlie,

Can you please clarify whether you want to add margins to a PDF file while creating a new one from scratch or an existing PDF file? Moreover, please elaborate your requirement with the help of some example, so we could guide you accordingly.

We’re sorry for the inconvenience.
Regards,