Scale or Resize PDFs on iOS

PSPDFKit’s Processor class can be used to scale pages of a document.

ℹ️ Note: The page scaling feature is only available if you have the Document Editor component enabled in your license.

Here’s how to scale pages via the Processor API:

// Create a default configuration.
let configuration = Processor.Configuration(document: document)!

// Scale the page down to half its size.
let pageInfo = document.pageInfoForPage(at: page)!
let pageSize = pageInfo.size
let newPageSize = CGSize(width: pageSize.width / 2, height: pageSize.height / 2)
configuration.scalePage(page, to: newPageSize)

// Start the conversion from `document` to `scaledDocumentURL`.
let processor = Processor(configuration: configuration, securityOptions: nil)
try processor.write(toFileURL: scaledDocumentURL)
// Create a default configuration.
PSPDFProcessorConfiguration *configuration = [[PSPDFProcessorConfiguration alloc] initWithDocument:document];

// Scale the page down to half its size.
PSPDFPageInfo *pageInfo = [document pageInfoForPageAtIndex:page];
CGSize pageSize = pageInfo.size;
CGSize newPageSize = CGSizeMake(pageSize.width/2.f, pageSize.height/2.f);
[configuration scalePage:page toSize:newPageSize];

// Start the conversion from `document` to `scaledDocumentURL`.
PSPDFProcessor *processor = [[PSPDFProcessor alloc] initWithConfiguration:configuration securityOptions:nil];
[processor writeToFileURL:scaledDocumentURL error:NULL];