Edit Text in PDFs on iOS

PSPDFKit enables you to edit text directly in PDF documents using the built-in user interface. Text is grouped by paragraphs, so you can edit multiple lines in a single text box. You can change the text color, the font type, and the font size, and you can move and resize text boxes. Content editing uses the native text input system, enabling all the text manipulation features and gestures common on iOS.

License

To edit text directly in PDF documents, contact Sales to add content editing to your license.

Enabling Content Editing

To enable content editing, add the contentEditingButtonItem toolbar item to the navigation bar when you configure your PDFViewController:

let controller = PDFViewController(document: document)
controller.navigationItem.setRightBarButtonItems([controller.contentEditingButtonItem], for: .document, animated: false)

This will add the content editing button to the right side of the navigation bar for entering content editing mode. Entering content editing mode will set its own left and right navigation item bar button items — a Cancel button and a Done button — for the .contentEditing view mode. If there are items for that view mode already set, which could happen due to setting navigationItem.rightBarButtonItems or navigationItem.leftBarButtonItems directly without assigning them to a specific view mode, contentEditingButtonItem will act as a toggle button to exit content editing mode.

Alternatively, to enable content editing after loading a document, set the view mode to .contentEditing:

let controller = PDFViewController(document: document)
controller.setViewMode(.contentEditing, animated: true)

Editing Text in a PDF Using the Built-In UI

To edit text in a PDF using the built-in UI, follow these steps:

  1. In the navigation toolbar, tap the Content Editor button.

  2. Double-tap within a text box on the page.

  3. Add or delete content in the text box.

  4. In the keyboard accessory toolbar, change the text color, font type, or font size. This toolbar isn’t available on macOS.

  5. In the navigation toolbar, click Done or the Content Editor button to save your changes.

Moving a Text Box

To move a text box, follow these steps:

  1. Tap on a text box to select it.

  2. Drag the text box to a different location.

Resizing a Text Box

To resize a text box, follow these steps:

  1. Tap on a text box to select it.

  2. Drag either of the two resize handles on the left or right side.

Supported Text Editing Functionalities

The following text editing functionalities are supported:

  • Adding new text and changing existing text using the colors and font types supported by PSPDFKit.

  • Adding new text and changing existing text using any font size.

  • Adding bold and italic text and changing existing text to bold and italic.

  • Selecting text with the native text selection handles or text selection gestures in the software keyboard.

  • Selecting and editing text using a hardware keyboard paired with your device.

  • Changing the size of a text box.

  • Changing the location of a text box.

Limitations

Text editing currently comes with the following limitations:

  • You can only edit left-to-right (LTR) text.

  • You cannot create new text boxes.

  • You cannot undo changes while in content editing mode.

  • You might not be able to recover text that you move outside the page. To recover text moved outside the page, cancel content editing or restore a previous backup of the document.

  • Changing text color, font type, or font size isn’t possible on macOS.