---
title: "Weekly Sponsor: PSPDFKit 📑"
url: https://littlebitesofcocoa.com/sponsor-415
author: Jake Marsh
published: 2017-02-17
topics: []
---

# Weekly Sponsor: PSPDFKit 📑

By Jake Marsh, February 17, 2017. HTML: https://littlebitesofcocoa.com/sponsor-415

_PDF files_ have been around [a long time](https://en.wikipedia.org/wiki/Portable_Document_Format). Over that time they evolved to become an incredibly versatile and functional format. They're also wide-ranging in terms of <i>how</i> they're used. Comic books, Apartment leases, flight manuals, etc. All powered by PDFs.

Being able to take advantage of all this great functionality in our apps would be huge for our users.

Today, we're welcoming a brand new sponsor to _LBOC_, it's [PSPDFKit](https://littlebitesofcocoa.com/campaigns/23/redirect)! [PSPDFKit](https://littlebitesofcocoa.com/campaigns/23/redirect) delivers an intuitive & seamless **SDK** for integrating _PDF_ functionality into apps on **iOS**, **Android**, and the **Web**.

With it, we can beautifully display _PDFs_, and allow our users to intuitively annotate documents, and much, <i>much</i> more.

Let's get started.

We'll head over to [PSPDFKit](https://littlebitesofcocoa.com/campaigns/23/redirect)'s [wonderful documentation area](https://pspdfkit.com/guides/ios/current/) and follow the <i>Getting Started</i> steps to integrate the Framework directly, or through a system like **CocoaPods**.

Once we've got [PSPDFKit](https://littlebitesofcocoa.com/campaigns/23/redirect) in our **app**, we can start playing around.

[PSPDFKit](https://littlebitesofcocoa.com/campaigns/23/redirect) provides [tons of great APIs](https://pspdfkit.com/guides/ios/current/features/detailed-list/) for programmtically interacting with PDF files, as well as a bunch of polished, (and [incredibly customizable](https://pspdfkit.com/guides/ios/current/customizing-the-interface/appearance-styling/)) user interfaces to allow our users to read and manipulate _PDF files_ themselves.

Let's try opening a _PDF_, and displaying it:

``` swift
let document = PSPDFDocument(url: documentURL)

let controller = PSPDFViewController(document: document, configuration: PSPDFConfiguration { builder in
    builder.thumbnailBarMode = .scrollable
    builder.scrollDirection = .horizontal
})
```

We create a new `PSPDFDocument`, then a new **view controller** to show it. We use [PSPDFKit](https://littlebitesofcocoa.com/campaigns/23/redirect)'s awesome `PSPDFConfiguration` type to neatly <i>build</i> up our settings.

From here we can simply present it like any other **view controller**. Neat!

[PSPDFKit](https://littlebitesofcocoa.com/campaigns/23/redirect) stands out with an awesome, well thought-out API. It's clear that they care deeply about API design, and developer experience.

Before we go, let's try out another couple features. First up, **Annotations**:

``` swift
// Create a new PSPDFDocument
let document = PSPDFDocument(url: documentURL)

// Create a link annotation, and set its URL
let linkAnnotation = PSPDFLinkAnnotation(url: URL(string: "https://pspdfkit.com")!)

// Position the annotation in the document
let boundingBox = CGRect(x: 200, y: 400, width: 50, height: 300)
linkAnnotation.boundingBox = boundingBox

// Customize the link annotation's appearance
PSPDFLinkAnnotationView.appearance().borderColor = .blue

// Add the newly created annotation to the document
document.add([linkAnnotation])
```

Very cool, Next up, **Forms**. Our users can of course fill out any **form fields** in documents they open, but we can actually fill them out programmtically too:

``` swift
let document = PSPDFDocument(url: documentURL)

guard let annotations = document.annotationsForPage(at: 0, type: .widget) else { return }

for annotation in annotations {
    switch annotation {
    case let textFieldFormElement as PSPDFTextFieldFormElement:
        guard let fieldName = textFieldFormElement.fieldName else { return }
        textFieldFormElement.contents = String(format: "Test %@", arguments: [fieldName])

    case let buttonFormElement as PSPDFButtonFormElement:
        buttonFormElement.toggleButtonSelectionStateAndSendNotification(true)
    default:
        break
    }
}
```

Very cool. We iterated through the form fields and filled them with some example content, and toggled the selected state for any buttons in the form.

We have truly only scratched the surface of what's possible with [PSPDFKit](https://littlebitesofcocoa.com/campaigns/23/redirect) here.

[PSPDFKit](https://littlebitesofcocoa.com/campaigns/23/redirect) offers a ton of other great features like [indexed search](https://pspdfkit.com/features/indexed-search/ios/), [digital signatures](https://pspdfkit.com/features/digital-signatures/ios/), and even [document editing](https://pspdfkit.com/features/document-editor/)! They also provide wonderfully fast and responsive support.

Be sure to check out [PSPDFKit's extensive Guides area](https://pspdfkit.com/guides/ios/current/) to find complete documentation and tons of extensive guides.

Thanks to [PSPDFKit](https://littlebitesofcocoa.com/campaigns/23/redirect) for their support of _LBOC_!
