Cropping PDF Pages in iOS

PSPDFKit for iOS lets you crop the pages of a document using Processor. To do this, load your document and then configure the page cropping parameters on a Processor.Configuration instance:

let document = ...

guard let configuration = Processor.Configuration(document: document) else {
    print("Could not create a processor configuration. The document might be locked or invalid.")
    return
}

// Crop the page to 200x200 pt.
configuration.changeCropBoxForPage(at: 0, to: CGRect(x: 0, y: 0, width: 200, height: 200))

let processor = Processor(configuration: configuration, securityOptions: nil)
do {
    // Write the modified document. This can be used to initialize
    // and present a new PSPDFKit document.
    try processor.write(toFileURL: destinationURL)
} catch {
    print(error)
}

To learn more about how to define the crop box, please consult our Coordinate Space Conversions guide.

ℹ️ Note: Cropping pages with Processor is only available if you have the Document Editor component enabled in your license.