---
title: "Add snake game inside PDF in Swift for iOS"
canonical_url: "https://www.nutrient.io/guides/ios/samples/snake/"
md_url: "https://www.nutrient.io/guides/ios/samples/snake.md"
last_updated: "2026-05-30T02:20:01.329Z"
description: "Enjoy a nostalgic game of old school snake! Explore our Swift code sample and dive into programming while having fun. Perfect for developers and gamers!"
---

# Add a snake game inside a PDF in Swift for iOS

Play a quick game of old school snake. :)

[Get Started](https://www.nutrient.io/sdk/ios/getting-started.md)

[All Samples](https://www.nutrient.io/guides/ios/samples.md)

[Download](https://www.nutrient.io/guides/ios/downloads.md)

[Launch Demo](https://www.nutrient.io/demo/)

---

```swift

//
//  Copyright © 2019-2026 PSPDFKit GmbH. All rights reserved.
//
//  The Nutrient sample applications are licensed with a modified BSD license.
//  Please see License for details. This notice may not be removed from this file.
//

import PSPDFKit
import PSPDFKitUI

class PSPDFSnakeExample: Example {

    override init() {
        super.init()
        title = "Snake Game"
        contentDescription = "Play a quick game of old school snake"
        category =.annotations
        priority = 500
    }

    // MARK: Create document and viewcontroller
    override func invoke(with delegate: ExampleRunnerDelegate) -> UIViewController? {
        let document = createDocument()
        let controller = SnakeViewController(document: document) {
            // Need to show the whole document
            $0.userInterfaceViewMode =.always
        }
        return controller
    }

    func createDocument() -> Document {
        // Set up configuration to create a new document.
        let configuration = Processor.Configuration()

        // Add an empty page
        let emptyPageTemplate = PageTemplate.blank
        let newPageConfiguration = PDFNewPageConfiguration(pageTemplate: emptyPageTemplate) {
            $0.pageMargins = UIEdgeInsets(top: 50, left: 50, bottom: 50, right: 50)
            $0.pageRotation =.rotation90
        }
        configuration.addNewPage(at: 0, configuration: newPageConfiguration)

        let outputFileURL = FileHelper.temporaryPDFFileURL(prefix: "new-document")
        do {
            // Invoke processor to create new document.
            let processor = Processor(configuration: configuration, securityOptions: nil)
            processor.delegate = self as? ProcessorDelegate
            try processor.write(toFileURL: outputFileURL)
        } catch {
            print("Error while processing document: \(error)")
        }

        let newDocument = Document(url: outputFileURL)
        newDocument.title = "Snake!"
        return newDocument
    }
}

private class SnakeViewController: PDFViewController {

    // MARK: Properties
    let increment = 20
    var xEnd = 70
    var yEnd = 210
    var score = 0

    enum Direction {
        case up
        case down
        case left
        case right
        case none
    }
    var currentDirection = Direction.none
    var previousDirection = Direction.none

    // Used to indicate the current state of the game
    enum GameState {
        case playing
        case paused
    }
    var currentGameState = GameState.paused

    var timer = Timer()

    // We use these properties to get our snake and apple since this way it's easier to work on the same object in various methods
    var snake: PolyLineAnnotation {
        return (self.document?.annotationsForPage(at: 0, type:.polyLine) as! [PolyLineAnnotation]).first!
    }
    var apple: LineAnnotation {
        return (self.document?.annotationsForPage(at: 0, type:.line) as! [LineAnnotation]).first!
    }

    // MARK: Initialization and key commands
    override func commonInit(with document: Document?, configuration: PDFConfiguration) {
        super.commonInit(with: document, configuration: configuration)
        // Create the snake and the apple
        createSnake()
        createApple()
        // Add the scoreboard
        let scoreButton = UIBarButtonItem(title: "Score: \(score)", style:.plain, target: self, action: nil)
        navigationItem.setRightBarButtonItems([scoreButton], animated: false)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        // Add the controls here since we need to make sure that the view is already loaded
        addSwipeGestures()
        addKeyCommands()
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        // Shows the instructions on how to control the snake at the beginning
        let instructionsController = UIAlertController(title: "Instructions", message: "To control the snake use your arrow keys on the keyboard or simply swipe in the direction you want to move.", preferredStyle:.alert)
        let start = UIAlertAction(title: "Got it!", style:.default)
        instructionsController.addAction(start)
        self.present(instructionsController, animated: true)
    }

    // Control the snake via the keyboard keys
    private func addKeyCommands() {
        let commands: [UIKeyCommand] = [
            UIKeyCommand(input: UIKeyCommand.inputUpArrow, modifierFlags: [], action: #selector(goUp)),

            UIKeyCommand(input: UIKeyCommand.inputDownArrow, modifierFlags: [], action: #selector(goDown)),

            UIKeyCommand(input: UIKeyCommand.inputLeftArrow, modifierFlags: [], action: #selector(goLeft)),

            UIKeyCommand(input: UIKeyCommand.inputRightArrow, modifierFlags: [], action: #selector(goRight)),

            UIKeyCommand(input: "p", modifierFlags: [], action: #selector(pause)),

        ]

        for command in commands {
            command.wantsPriorityOverSystemBehavior = true
            command.allowsAutomaticMirroring = false

            addKeyCommand(command)
        }
    }

    // Control the snake via swipe gestures
    func addSwipeGestures() {
        let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(goLeft))

        swipeLeft.direction =.left
        view.addGestureRecognizer(swipeLeft)

        let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(goRight))

        swipeRight.direction =.right
        view.addGestureRecognizer(swipeRight)

        let swipeUp = UISwipeGestureRecognizer(target: self, action: #selector(goUp))

        swipeUp.direction =.up
        view.addGestureRecognizer(swipeUp)

        let swipeDown = UISwipeGestureRecognizer(target: self, action: #selector(goDown))

        swipeDown.direction =.down
        view.addGestureRecognizer(swipeDown)
    }

    // MARK: Game States
    // Pause and restart function if you need to step away for a second
    @objc func pause() {
        if currentDirection!=.none {
            previousDirection = currentDirection
        }
        currentDirection =.none
        let alertController = UIAlertController(title: "Game Paused", message: "", preferredStyle:.alert)
        let alert = UIAlertAction(title: "Resume", style:.default, handler: { _ in self.restart() })
        alertController.addAction(alert)
        self.present(alertController, animated: true)
    }

    @objc func restart() {
        currentDirection = previousDirection
    }

    // For ending the game and resetting everything to the starting position
    func gameOver() {
        score = 0
        currentDirection =.none
        currentGameState =.paused

        let linesAndPolyLines = document?.annotationsForPage(at: pageIndex, type: [.line,.polyLine])
        document!.remove(annotations: linesAndPolyLines!)
        createApple()
        updateScore()
        createSnake()
    }

    // MARK: Timer
    func setupTimer() {
        if currentGameState ==.paused {
            timer = Timer.scheduledTimer(timeInterval: 0.2, target: self, selector: #selector(timerFired), userInfo: nil, repeats: true)

        }
    }

    @objc func timerFired() {
        didBiteSelf()
        didEatApple()
        didLeaveArea()
        goDirection(direction: currentDirection)
    }

    // MARK: Directions
    @objc func goUp() {
        if currentDirection ==.down {
            return
        }
        currentDirection =.up
        setupTimer()
    }

    @objc func goDown() {
        if currentDirection ==.up {
            return
        }
        currentDirection =.down
        setupTimer()
    }

    @objc func goLeft() {
        if currentDirection ==.right {
            return
        }
        currentDirection =.left
        setupTimer()
    }

    @objc func goRight() {
        if currentDirection ==.left {
            return
        }
        currentDirection =.right
        setupTimer()
    }

    func goDirection(direction: Direction) {
        var points = snake.points
        currentGameState =.playing
        switch direction {
        case.up:
            yEnd += increment
        case.down:
            yEnd -= increment
        case.left:
            xEnd -= increment
        case.right:
            xEnd += increment
        case.none:
            return
        }

        points?.append(CGPoint(x: xEnd, y: yEnd))
        points?.remove(at: 0)
        snake.points = points
        document?.documentProviderForPage(at: snake.pageIndex)?.annotationManager.update([snake], animated: true)
    }

    // MARK: Create Objects
    func createSnake() {
        let snake = PolyLineAnnotation()
        let xStart = 70
        let yStart = 10
        xEnd = 70
        yEnd = 210
        var points = [CGPoint(x: xStart, y: yStart)]
        for i in 1...10 {
            points.append(CGPoint(x: xStart, y: yStart + increment * i))
        }
        snake.points = points
        snake.color =.blue
        snake.lineWidth = 20
        document?.add(annotations: [snake])
    }

    @objc func createApple () {
        let apple = LineAnnotation()
        // Page boundaries are 600x840
        // Need to create them in 20 increments since it needs to allign exactly with the snake's path
        var randomX = Int.random(in: 0...41)
        var randomY = Int.random(in: 0...29)
        randomX *= 20
        randomY *= 20
        // We need the +10 because otherwise the point could be halfway outside the page, since it's starting point is in the middle of the annotation
        randomX += 10

        // This will create a 20x20 square which is our apple
        apple.points = [CGPoint(x: randomX, y: randomY), CGPoint(x: randomX, y: randomY + 20)]
        apple.lineWidth = 20
        apple.color =.red

        document?.add(annotations: [apple])
    }

    // MARK: Actions
    func didEatApple() {
        guard let lastSnakePoint = snake.points?.last else { return }
        guard let lastApplePoint = apple.points?.last else { return }
        guard let firstApplePoint = apple.points?.first else { return }

        // Since the apple is made from 2 points, we need to check if the head of our snake is between those
        if lastSnakePoint.y <= lastApplePoint.y && lastSnakePoint.y >= firstApplePoint.y && lastSnakePoint.x <= lastApplePoint.x && lastSnakePoint.x >= firstApplePoint.x {
            addTail()
        } else {
            return
        }
        score += 1
        updateScore()
        document?.remove(annotations: (document?.annotationsForPage(at: pageIndex, type:.line))!)
        // Need to create a new one once the old one gets eaten
        createApple()
    }

    func didBiteSelf() {
        guard let snakePoints = snake.points?.count else { return }
        guard let lastSnakePoint = snake.points?.last else { return }

        // Check for each point in the snake. Can't coun't in our own head though!
        for snakePoint in 0...snakePoints - 2 {
            if lastSnakePoint.x == snake.points![snakePoint].x && lastSnakePoint.y == snake.points![snakePoint].y && currentGameState ==.playing {
                timer.invalidate()
                let alertController = UIAlertController(title: "Ouch, don't bite yourself!", message: "", preferredStyle:.alert)
                let alert = UIAlertAction(title: "Restart Game", style:.default, handler: { _ in self.gameOver() })
                alertController.addAction(alert)
                self.present(alertController, animated: true)
                currentDirection =.none
            }
        }
    }

    func didLeaveArea() {
        guard let lastSnakePoint = snake.points?.last else { return }
        guard let documentHeight = document?.pageInfoForPage(at: pageIndex)?.size.height else { return }
        guard let documentWidth = document?.pageInfoForPage(at: pageIndex)?.size.width else { return }

        if (lastSnakePoint.x >= documentWidth || lastSnakePoint.x < 0 || lastSnakePoint.y >= documentHeight || lastSnakePoint.y < 0) && currentGameState ==.playing {
            timer.invalidate()
            let alertController = UIAlertController(title: "Don't leave the area!", message: "", preferredStyle:.alert)
            let alert = UIAlertAction(title: "Restart Game", style:.default, handler: { _ in self.gameOver() })
            alertController.addAction(alert)
            self.present(alertController, animated: true)
            currentDirection =.none
        }
    }

    func addTail() {
        // This is just a placeholder so the values don’t matter. This point will immediately be removed in `goDirection`.
        snake.points?.insert(CGPoint(x: 0, y: 0), at: 0)
    }

    func updateScore() {
        navigationItem.rightBarButtonItem?.title = "Score: \(score)"
    }
}

```

This code sample is an example that illustrates how to use our SDK. Please adapt it to your specific use case.

---

## Related pages

- [Customize PDF page lables in Swift for iOS](/guides/ios/samples/custom-page-label.md)
- [Add file annotation to PDF in Swift for iOS](/guides/ios/samples/add-file-annotation-with-embedded-file.md)
- [Add a custom cloudy rectangle annotation to a PDF in Swift for iOS](/guides/ios/samples/add-custom-cloudy-rectangle.md)
- [Add an image signature to PDF in Swift for iOS](/guides/ios/samples/add-image-signature-to-pdf-programmatically.md)
- [Add an Apple Maps widget to a PDF page in Swift for iOS](/guides/ios/samples/add-map-widget-to-pdf.md)
- [Add video annotation to PDF in Swift for iOS](/guides/ios/samples/add-video-annotation-to-pdf.md)
- [Image annotations in Swift for iOS](/guides/ios/samples/annotate-images.md)
- [Add image gallery to PDF in Swift for iOS](/guides/ios/samples/add-image-gallery-to-pdf.md)
- [Add annotation buttons to PDF toolbar in Swift for iOS](/guides/ios/samples/annotation-buttons-in-navigation-bar.md)
- [Customize blend modes in stamp annotations in Swift for iOS](/guides/ios/samples/annotation-inspector-stamp-blend-mode.md)
- [Add analytics to PDF components in Swift for iOS](/guides/ios/samples/analytics.md)
- [Create an always-dark annotation toolbar in Swift for iOS](/guides/ios/samples/always-dark-annotation-toolbar.md)
- [Creating effective link annotations on iOS](/guides/ios/samples/annotations.md)
- [Maintain annotation aspect ratio in Swift](/guides/ios/samples/aspect-ratio-conserving-resizing.md)
- [Create a custom appearance stream generator in Swift for iOS](/guides/ios/samples/appearance-stream-generator.md)
- [Write PDF annotations to XFDF in Swift for iOS](/guides/ios/samples/annotations-to-xfdf.md)
- [Add copyright watermark to PDF in Swift for iOS](/guides/ios/samples/add-copyright-watermark-to-pdf.md)
- [Add text annotation to PDF in Swift for iOS](/guides/ios/samples/add-text-annotation-to-pdf.md)
- [Embed, flatten, or remove PDF annotations in Swift for iOS](/guides/ios/samples/annotation-processing.md)
- [Add calculator to PDF using JavaScript on iOS](/guides/ios/samples/calculator.md)
- [Enable auto-save in PDF using Swift for iOS](/guides/ios/samples/auto-saving-pdf.md)
- [Blur PDF page in Swift for iOS](/guides/ios/samples/blur-pdf-pages.md)
- [Programatically create PDF annotations in Swift for iOS](/guides/ios/samples/add-annotations-to-pdf-programmatically.md)
- [Using a custom annotation provider in Swift for iOS](/guides/ios/samples/annotation-provider-with-rotation.md)
- [Asynchronously sign PDF in Swift for iOS](/guides/ios/samples/asynchronous-digital-signature-in-pdf.md)
- [Embed PDFViewController as a child in iOS](/guides/ios/samples/child-view-controller.md)
- [PDFViewController controller state in Swift for iOS](/guides/ios/samples/controller-state.md)
- [Collaborating on PDFs in board meetings using Swift for iOS](/guides/ios/samples/board-meeting.md)
- [Create link annotations in PDF using Swift for iOS](/guides/ios/samples/create-link-annotation-in-pdf.md)
- [Embed Nutrient as a child view controller in Swift for iOS](/guides/ios/samples/child-view-controller-using-parent-navigation-bar.md)
- [Present a confirmation sheet for iOS annotations](/guides/ios/samples/confirm-annotation-deletion.md)
- [Prepare PDF to capture digital signature in Swift for iOS](/guides/ios/samples/contained-digital-signatures.md)
- [Prepare PDF to embed PAdES digital signature in Swift for iOS](/guides/ios/samples/contained-pades-digital-signature.md)
- [Create PDF bookmark with UI in Swift for iOS](/guides/ios/samples/create-pdf-bookmark-name-ui.md)
- [Add a custom free text input accessory in Swift for iOS](/guides/ios/samples/custom-free-text-input-accessory.md)
- [Custom annotation provider in Swift for iOS](/guides/ios/samples/custom-annotation-provider.md)
- [Create password-protected PDF in Swift for iOS](/guides/ios/samples/create-password-protected-pdf.md)
- [Continiously create free text annotations in Swift for iOS](/guides/ios/samples/create-free-text-annotations-continuously.md)
- [Aviation example: Displaying flight plan PDF in Swift for iOS](/guides/ios/samples/aviation.md)
- [Clear all PDF annotations with a button in Swift for iOS](/guides/ios/samples/custom-button-in-annotation-toolbar.md)
- [Select PDF text and create a note in Swift for iOS](/guides/ios/samples/create-note-from-selection.md)
- [Customize annotation link border color in Swift for iOS](/guides/ios/samples/custom-link-border-color.md)
- [Create PDF programmatically in Swift for iOS](/guides/ios/samples/create-pdf-programmatically.md)
- [Add custom font sizes to free text keyboard in Swift for iOS](/guides/ios/samples/custom-buttons-free-text-keyboard-toolbar.md)
- [Custom PDF bookmark provider in Swift for iOS](/guides/ios/samples/custom-pdf-bookmark-provider.md)
- [Custom Comments Ui](/guides/ios/samples/custom-comments-ui.md)
- [Use a custom image picker controller in Swift for iOS](/guides/ios/samples/custom-image-picker-controller.md)
- [Customize PDF outline in Swift for iOS](/guides/ios/samples/custom-pdf-outline-controller.md)
- [Display building floor plans in iOS with Swift](/guides/ios/samples/construction.md)
- [Customize PDF sharing options in Swift for iOS](/guides/ios/samples/custom-pdf-sharing-options.md)
- [Custom Thumbnail Page Label](/guides/ios/samples/custom-thumbnail-page-label.md)
- [Customize pencil interactions on PDF using Swift for iOS](/guides/ios/samples/custom-pencil-interaction-action.md)
- [Custom thumbnail PDF view filter in Swift for iOS](/guides/ios/samples/custom-thumbnail-view-controller-filter.md)
- [Customize the search result cell in Swift for iOS](/guides/ios/samples/custom-search-result-cell.md)
- [Customize PDF tab titles in Swift for iOS](/guides/ios/samples/custom-tabbed-bar-title.md)
- [Customize PDF annotation toolbar in Swift for iOS](/guides/ios/samples/customize-pdf-annotation-toolbar.md)
- [Custom PDF stamp annotation in Swift for iOS](/guides/ios/samples/custom-pdf-stamp-annotations.md)
- [Customize the filename of shared PDF in Swift for iOS](/guides/ios/samples/custom-sharing-filenames.md)
- [Customized note annotation view controller in Swift for iOS](/guides/ios/samples/customized-note-annotation-view-controller.md)
- [How to disable digital signature removal in PDFs](/guides/ios/samples/disable-removing-digital-signature.md)
- [Disable PDF annotation editing in Swift for iOS](/guides/ios/samples/disable-annotation-editing.md)
- [Disable annotations reviews in PDF using Swift for iOS](/guides/ios/samples/disable-annotation-reviews.md)
- [Display PDF in inbox directory using Swift for iOS](/guides/ios/samples/display-pdf-inbox.md)
- [Initialize a PDF with data in Swift for iOS](/guides/ios/samples/document-data-provider-pdf-from-data.md)
- [Disable bookmark editing in PDF using Swift for iOS](/guides/ios/samples/disable-bookmark-editing.md)
- [Add watermark to all PDF pages using Swift for iOS](/guides/ios/samples/draw-watermark-on-pdf-pages.md)
- [Encrypt and decrypt a PDF using Swift for iOS](/guides/ios/samples/encrypt-decrypt-pdf.md)
- [Customize the PDF search highlight color in Swift for iOS](/guides/ios/samples/custom-search-highlight-color.md)
- [Save reading position in PDF using Swift for iOS](/guides/ios/samples/document-view-state-restoration.md)
- [Disable scroll bouncing in PDF using Swift for iOS](/guides/ios/samples/disable-scroll-bouncing.md)
- [Implement a Document Picker sidebar in Swift for iOS](/guides/ios/samples/document-picker-sidebar.md)
- [Document With Original Url Set](/guides/ios/samples/document-with-original-url-set.md)
- [Encrypt disk cache when rendering PDF in Swift for iOS](/guides/ios/samples/encrypted-cache.md)
- [PDF highlight annotation blend mode menu in Swift for iOS](/guides/ios/samples/highlight-annotation-blend-mode-menu.md)
- [Fixed-sized PDF stamp annotations in Swift for iOS](/guides/ios/samples/floating-pdf-stamp-annotation.md)
- [Exit PDF drawing mode automatically in Swift for iOS](/guides/ios/samples/exit-drawing-mode-automatically.md)
- [Apply XFDF annotations and save it as new PDF in Swift for iOS](/guides/ios/samples/embedded-xfdf-annotation-provider.md)
- [Allow freeform image annotation resizing in Swift for iOS](/guides/ios/samples/freeform-image-resize.md)
- [Disable bookmark renaming in PDF using Swift for iOS](/guides/ios/samples/disable-bookmark-renaming.md)
- [Convert HTML to PDF using Swift for iOS](/guides/ios/samples/html-to-pdf.md)
- [Add video, audio, image annotation to PDF in Swift for iOS](/guides/ios/samples/gallery.md)
- [Add a bottom inset to the user interface in Swift for iOS](/guides/ios/samples/inset-user-interface.md)
- [Insert page into PDF from another document in Swift for iOS](/guides/ios/samples/insert-pdf-page-from-document.md)
- [Customize comment font size in PDF using Swift for iOS](/guides/ios/samples/large-font-for-comments.md)
- [Monitor UI touches using Swift for iOS](/guides/ios/samples/monitor-touches.md)
- [Customize PDF form appearance in Swift for iOS](/guides/ios/samples/customizing-pdf-form-appearance.md)
- [Customize the annotation selection knobs in Swift for iOS](/guides/ios/samples/custom-selection-knobs.md)
- [Customize vertical annotation toolbar in Swift for iOS](/guides/ios/samples/custom-vertical-annotation-toolbar.md)
- [Customize the annotations list in Swift for iOS](/guides/ios/samples/customizing-annotation-list.md)
- [Encrypted Xfdf Annotation Provider](/guides/ios/samples/encrypted-xfdf-annotation-provider.md)
- [Face redaction in document using Swift for iOS](/guides/ios/samples/face-redaction-in-pdf.md)
- [Draw all PDF annotations as overlays in Swift for iOS](/guides/ios/samples/draw-annotations-as-overlay.md)
- [Configuring PDF reader in Swift for iOS](/guides/ios/samples/e-reader.md)
- [Customize PDF view margins using Swift for iOS](/guides/ios/samples/dynamic-margins.md)
- [Lazy load PDF annotations in Swift for iOS](/guides/ios/samples/lazy-load-pdf-annotations.md)
- [Highlight text in PDF using Swift for iOS](/guides/ios/samples/highlight-text-in-pdf.md)
- [LMS example: Take and grade an exam using Swift for iOS](/guides/ios/samples/e-learning.md)
- [Using Instant JSON to collaborate on PDFs in Swift for iOS](/guides/ios/samples/instant-json.md)
- [Generate a PDF report using Swift for iOS](/guides/ios/samples/generate-pdf-report.md)
- [Hide or reveal an area in a PDF using Swift for iOS](/guides/ios/samples/hide-reveal-area-in-pdf.md)
- [Configuring multiline titles in PDF using Swift for iOS](/guides/ios/samples/multiline-pdf-title.md)
- [Link annotation view customization in Swift for iOS](/guides/ios/samples/link-annotation-view-customization.md)
- [OCR PDF using Swift for iOS](/guides/ios/samples/ocr-pdf.md)
- [Add overlay views to PDF in Swift for iOS](/guides/ios/samples/overlay-views.md)
- [Custom PDF page labels in the sharing UI in Swift for iOS](/guides/ios/samples/page-labels-in-sharing-ui.md)
- [Open AES-encrypted PDF in Swift for iOS](/guides/ios/samples/open-aes-encrypted-pdf.md)
- [Password Not Preset](/guides/ios/samples/password-not-preset.md)
- [Custom saving options after editing PDF in Swift for iOS](/guides/ios/samples/pdf-editor-custom-saving-confirmation.md)
- [Customize PDF editor toolbar using Swift for iOS](/guides/ios/samples/pdf-editor-toolbar-customization.md)
- [Toggle PDF form field highlight color in Swift for iOS](/guides/ios/samples/pdf-form-highlight-color.md)
- [Render drawings on PDF pages using Swift for iOS](/guides/ios/samples/pdf-page-drawing.md)
- [Custom page template in PDF editor using Swift for iOS](/guides/ios/samples/pdf-editor-custom-templates.md)
- [PDF reflow with Reader View in Swift for iOS](/guides/ios/samples/pdf-reader-view.md)
- [Create email snippet when sharing PDF in Swift for iOS](/guides/ios/samples/predefined-email-body.md)
- [Create PDF teleprompter using Swift for iOS](/guides/ios/samples/pdf-teleprompter.md)
- [Printer defaults for PDF annotations in Swift for iOS](/guides/ios/samples/printer-defaults.md)
- [Redact text in PDF using Swift for iOS](/guides/ios/samples/pdf-redaction.md)
- [Persist view settings using Swift for iOS](/guides/ios/samples/persist-view-settings.md)
- [Display PDFViewController in popover using Swift for iOS](/guides/ios/samples/popover-presentation.md)
- [Open PDF with preset password using Swift for iOS](/guides/ios/samples/preset-pdf-passwords.md)
- [Customize PDF view settings in Swift for iOS](/guides/ios/samples/pdf-view-settings.md)
- [Getting started with iOS playground](/guides/ios/samples/playground.md)
- [Programmatically edit PDFs using Swift for iOS](/guides/ios/samples/programmatic-pdf-editing.md)
- [Customize iOS annotation inspector color presets](/guides/ios/samples/preset-customization.md)
- [Download PDF from URL using Swift for iOS](/guides/ios/samples/remote-document-url.md)
- [Programmatically go to PDF outline in Swift for iOS](/guides/ios/samples/programmatically-go-to-outline.md)
- [Remove password from PDF using Swift for iOS](/guides/ios/samples/remove-pdf-password.md)
- [Rotate PDF page using Swift for iOS](/guides/ios/samples/rotate-pdf-page.md)
- [Rotate PDF pages with Swift](/guides/ios/samples/rotate-page-temporarily.md)
- [Configure PDF annotation toolbar using Swift for iOS](/guides/ios/samples/manual-toolbar-setup.md)
- [Cycle through PDF documents using Swift for iOS](/guides/ios/samples/page-view-controller.md)
- [PDF collaboration using Swift for iOS](/guides/ios/samples/pdf-collaboration.md)
- [Show PDF download progress in Swift for iOS](/guides/ios/samples/pdf-download-progress.md)
- [Compare PDF documents using Swift for iOS](/guides/ios/samples/pdf-document-comparison.md)
- [PDF magazine reader using Swift for iOS](/guides/ios/samples/pdf-magazine-reader.md)
- [PDF text redaction using regex in Swift for iOS](/guides/ios/samples/redact-pdf-text-using-regex.md)
- [PDF page scale and resize using Swift for iOS](/guides/ios/samples/pdf-page-scaling.md)
- [Auto-save PDF annotation changes in Swift for iOS](/guides/ios/samples/save-as-pdf.md)
- [Customize scrubber bar with buttons using Swift for iOS](/guides/ios/samples/scrubber-bar-with-buttons.md)
- [Programtically search a PDF using Swift for iOS](/guides/ios/samples/search-without-controller.md)
- [Enable saving confirmation when exiting PDF in Swift for iOS](/guides/ios/samples/save-confirmation.md)
- [Customize view controller for screen mirroring in Swift for iOS](/guides/ios/samples/screen-mirroring.md)
- [Search multiple PDF files using Swift for iOS](/guides/ios/samples/search-multiple-pdf-files.md)
- [Select all text in a PDF using Swift for iOS](/guides/ios/samples/select-all-pdf-text.md)
- [Select free text annotation in PDF using Swift for iOS](/guides/ios/samples/select-free-text-annotations.md)
- [Show multiple files as a single PDF using Swift for iOS](/guides/ios/samples/show-multiple-files-in-pdf.md)
- [Show note controller for highlights in Swift for iOS](/guides/ios/samples/show-note-controller-for-highlights.md)
- [Simplifying the font picker for text annotation using Swift for iOS](/guides/ios/samples/simple-font-picker.md)
- [Simplifying the annotation inspector using Swift for iOS](/guides/ios/samples/simple-annotation-inspector.md)
- [Convert stamp into a PDF button in Swift for iOS](/guides/ios/samples/stamp-button.md)
- [Create a custom PDF navigation bar with SwiftUI for iOS](/guides/ios/samples/swiftui-custom-navigation-bar.md)
- [Embed a SwiftUI view inside a page view on iOS](/guides/ios/samples/swiftui-on-page-view.md)
- [SwiftUI split screen: Display two PDF views side by side on iOS](/guides/ios/samples/swiftui-split-screen.md)
- [Enable fixed PDF toolbar position in Swift for iOS](/guides/ios/samples/top-toolbar-position.md)
- [Swiftui Sharing](/guides/ios/samples/swiftui-sharing.md)
- [Use PDFViewController with SwiftUI for iOS](/guides/ios/samples/swiftui.md)
- [Update configuration when rotating PDF in Swift for iOS](/guides/ios/samples/update-configuration-when-rotating.md)
- [Show or hide PDF annotations using Swift for iOS](/guides/ios/samples/toggle-annotation-visibility.md)
- [Multi-user PDF collaboration using Swift for iOS](/guides/ios/samples/multi-user-pdf-collaboration.md)
- [Convert MS Office (DOCX, XLSX, PPTX) to PDF in Swift for iOS](/guides/ios/samples/office-to-pdf-conversion.md)
- [Display measurements on PDF pages or spreads in Swift for iOS](/guides/ios/samples/measurements-on-pages-spreads.md)
- [Search and redact text in a PDF using Swift for iOS](/guides/ios/samples/search-and-redact-pdf-text.md)
- [Show author name on annotation selection in Swift for iOS](/guides/ios/samples/show-author-name-on-annotation-selection.md)
- [Programmatically add a signature to all PDF pages using Swift for iOS](/guides/ios/samples/sign-all-pdf-pages.md)
- [Store PDF annotations for multiple users in Swift for iOS](/guides/ios/samples/store-multiple-user-annotations.md)
- [PDF streaming using Swift for iOS](/guides/ios/samples/streaming-pdf.md)
- [Sticky header for PDF thumbnail view in Swift for iOS](/guides/ios/samples/sticky-header.md)
- [PDF streaming with SwiftUI for iOS](/guides/ios/samples/streaming-pdf-swiftui.md)
- [Create a custom PDF page setting view in SwiftUI for iOS](/guides/ios/samples/swiftui-settings.md)
- [Customize PDF annotation toolbar with SwiftUI for iOS](/guides/ios/samples/swiftui-annotationt-toolbar.md)
- [Custom annotation inspector with SwiftUI for iOS](/guides/ios/samples/swiftui-custom-annotation-inspector.md)
- [Import and export annotations in XFDF using Swift for iOS](/guides/ios/samples/xfdf-annotation-provider.md)
- [Add SwiftUI sidebar next to PDF view on iOS](/guides/ios/samples/swiftui-sidebar.md)
- [Show multiple PDFs with tabbed UI using Swift for iOS](/guides/ios/samples/tabbed-bar.md)
- [Integrate UIStoryboard with PDFViewController in Swift for iOS](/guides/ios/samples/storyboard.md)
- [Display PDF annotations on layers in Swift for iOS](/guides/ios/samples/pdf-annotation-layers.md)
- [PDF form examples using Swift for iOS](/guides/ios/samples/pdf-forms.md)

