We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Cropping a PDF


Is is possible to crop a PDF before it is converted to an image file type. I saw multiple ways to convert the PDF page directly, but my requirement is to crop the PDF to a general area on the page that has content, prior to making it an image.

Hello Oscar,

Thanks for using our products.
<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>

am afraid currently Aspose.Pdf for .NET does not support the feature of converting certain region of page into image format. However for the sake of implementation, I have logged this requirement in our issue tracking system as PDFNEWNET-30267 under new features list. We will further investigate this
requirement in details and will keep you updated on the status of a correction.<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””><span style=“font-size:10.0pt;

We apologize for your inconvenience.

Hello Oscar,

Thanks for your patience. We have further investigated this requirement and I am pleased to share that your requirement can be accomplished using following code snippet. Please try using it and in case you face any problem or you have any further query, please feel free to contact.

// load the source PDF document
Document pdfDocument = new Document(“D:\pdftest\TEST01.pdf”);
// create a Ractable object to hold crop box
Aspose.Pdf.Rectangle cropBox = pdfDocument.Pages[1].CropBox;
// update page’s crop box
pdfDocument.Pages[1].CropBox = new Aspose.Pdf.Rectangle(cropBox.LLX + 140, cropBox.LLY + 140, cropBox.URX - 140, cropBox.URY - 140);
// create PngDevice object
PngDevice pngDevice = new PngDevice();
// Save extracted page region to PNG image format
pngDevice.Process(pdfDocument.Pages[1], “D:\pdftest\TEST01.png”);