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.

  • 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 PSPDFCatalog.xcodeproj.
  2. Build and run the PSPDFCatalog 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 CocoaPods, manually, and with Carthage. They are outlined below.

CocoaPods

If you’re already using CocoaPods, the simplest way to add PSPDFKit and PSPDFKitOCR to your project is to add 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

If you’re not using CocoaPods and don’t plan to, follow the steps below for manual integration or integration with Carthage.

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 DMG and then manually add the language files located in PSPDFKitOCR/Languages to your target.