Integrating Our OCR SDK into iOS

This guide explains the process of integrating the OCR framework of PSPDFKit for iOS into your project.

Requirements

  • PSPDFKit for iOS with PSPDFKitOCR

PSPDFKit and PSPDFKitOCR are two separate dynamic frameworks available in the same download. Download the latest release from my.pspdfkit.com, or for evaluation purposes, check out our free trial and download the latest release, or use Swift Package Manager (see the integration section below).

  • The latest stable version of Xcode

PSPDFKit and PSPDFKitOCR require the latest stable version of Xcode available at the time the release was made.

Quick Start with the Catalog Example

You can find runnable sample code in OCRExample.swift. It showcases how PSPDFKitOCR works in our PSPDFKit Catalog sample project:

  1. Open Catalog.xcodeproj.

  2. Build and run the Catalog scheme.

  3. Search for OCR in the examples list and open the example.

Integrating the PSPDFKitOCR Framework

There are three ways to integrate the PSPDFKitOCR framework: with Swift Package Manager, with CocoaPods, and manually. They’re outlined below.

Swift Package Manager

If you’re already using Swift Package Manager, you can add PSPDFKitOCR to your project like so:

  1. Integrate the PSPDFKit Swift package.

  2. Integrate the PSPDFKitOCR Swift package using the public repository URL.

https://github.com/PSPDFKit/PSPDFKitOCR-SP

add-swift-package

  1. Download the latest language files.

  2. Manually add the language files you need to your target. add-language-file-bundle

CocoaPods

If you’re already using CocoaPods, you can add PSPDFKit and PSPDFKitOCR to your project by adding the following to your Podfile:

use_frameworks!

target :YourTargetName do
	pod 'PSPDFKit',
	    podspec: 'https://my.pspdfkit.com/pspdfkit-ios/latest.podspec'
	pod 'PSPDFKitOCR',
	    podspec: 'https://my.pspdfkit.com/ocr/latest.podspec'
end

Then run pod install.

PSPDFKitOCR ships with individual language bundles that can all be separately integrated in your app. This is so you only use the ones you actually need, which avoids unnecessarily bloating your app’s size.

ℹ️ Note: The example above will download and include in your app all the trained data models for every language we support. If you’re looking to only implement OCR for a subset of the supported languages, you’ll need to modify your Podfile like shown below:

use_frameworks!

target :YourTargetName do
	pod 'PSPDFKit',
	    podspec: 'https://my.pspdfkit.com/pspdfkit-ios/latest.podspec'

	pod 'PSPDFKitOCR/PSPDFKitOCR',
	    podspec: 'https://my.pspdfkit.com/ocr/latest.podspec'

	pod 'PSPDFKitOCR/English',
	    podspec: 'https://my.pspdfkit.com/ocr/latest.podspec'

	pod 'PSPDFKitOCR/German',
	    podspec: 'https://my.pspdfkit.com/ocr/latest.podspec'
end

Manually

To integrate manually:

  1. Integrate PSPDFKit.

  2. Drag PSPDFKitOCR.xcframework into the Frameworks, Libraries, and Embedded Content section of your target.

  3. Manually add the language files located in PSPDFKitOCR/Languages to your target. add-language-file-bundle