Cropping PDF pages on Android

Nutrient Android SDK lets you crop the pages of a document using the Processor API. To do this, load your document and then configure the parameters for page cropping on a PdfProcessorTask instance:

val task = PdfProcessorTask.fromDocument(document)
// Crop the page to 200×200 pt.
task.setPageBox(0, PdfBox.CROP_BOX, RectF(0f, 0f, 200f, 200f))
val outputFile = File(context.filesDir, "cropped-document.pdf")
PdfProcessor.processDocument(task, outputFile)
final PdfProcessorTask task = PdfProcessorTask.fromDocument(document);
// Crop the page to 200×200 pt.
task.setPageBox(0, PdfBox.CROP_BOX, new RectF(0, 0, 200, 200));
final File outputFile = new File(context.getFilesDir(), "cropped-document.pdf");
PdfProcessor.processDocument(task, outputFile);

To learn more about how to define the crop box, consult our coordinate space conversions guide.

Information

Cropping pages with the Processor API is only available if you have the Document Editor enabled in your license.