Getting Started

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 customers.pspdfkit.com, or for evaluation purposes, fill out the trial form 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 four ways to integrate the PSPDFKitOCR framework: with Swift Package Manager, with CocoaPods, manually, and with Carthage. They are 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.
1
https://github.com/PSPDFKit/PSPDFKitOCR-SP

  1. Download the latest language files.
  2. Manually add the language files you need to your target.

CocoaPods

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

Copy
1
2
3
4
5
6
7
8
use_frameworks!

target :YourTargetName do
  pod 'PSPDFKit',
      podspec: 'https://customers.pspdfkit.com/pspdfkit-ios/latest.podspec'
  pod 'PSPDFKitOCR',
      podspec: 'https://customers.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.

Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use_frameworks!

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

  # Subspec for the PSPDFKitOCR framework.
  pod 'PSPDFKitOCR/PSPDFKitOCR',
      podspec: 'https://customers.pspdfkit.com/ocr/latest.podspec'

  # Subspec for the English language file.
  pod 'PSPDFKitOCR/English',
      podspec: 'https://customers.pspdfkit.com/ocr/latest.podspec'

  # Subspec for the German language file.
  pod 'PSPDFKitOCR/German',
      podspec: 'https://customers.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.

Carthage

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

1
2
binary "https://customers.pspdfkit.com/pspdfkit-ios.json"
binary "https://customers.pspdfkit.com/ocr.json"

Then run carthage update.

ℹ️ Note: Since Carthage doesn’t currently support adding resource files, you’ll need to download the latest language files and then manually add them to your target.