Crop PDF Pages in C#

While dealing with PDF files programmatically, you often need to crop the pages in a PDF. This could be useful when you have to trim the empty margins, content in the header/footer, and so on. To accomplish that, this article provides you with an easy way of cropping PDF pages in C#. So let’s have a look at how to do it in a .NET application.

C# Library to Crop PDF

To crop PDF files, we will use Aspose.PDF for .NET, which is a powerful library to process, create, and manipulate PDF files. You can either download the library or install it in your C# application using the following NuGet command:

PM> Install-Package Aspose.PDF

Crop a PDF File in C#

Cropping the pages in a PDF file becomes easy with the help of Aspose.PDF for .NET. You only need to load the PDF, specify the size of the cropping box, and that is it. Let’s see how to crop a page in a PDF using C#.

The following code sample shows how to crop a page in a PDF using C#.

Crop PDF Online

We also provide a free app to crop PDF pages, which is based on Aspose.PDF for .NET. You can use this PDF cropping app without creating an account.

Free C# PDF Library

You can evaluate our C# PDF library without any limitations using a free temporary license. Also, you can visit the documentation to explore other features of the library.

In case you would find any issues while using our library, you can contact us via our forum.

Conclusion

This article demonstrated how to crop pages in a PDF file using C#. Following a few simple steps and writing a few lines of code you can crop the desired PDF pages programmatically. In addition, we have provided you with a web-based app to crop PDF files online. You can use this online PDF cropper absolutely free without creating an account.

See Also