Edit Text in PDFs on Android

Starting with PSPDFKit 8.7 for Android, you can edit text directly in PDF documents using the built-in user interface. You can also change text color, font type, and font size, as well as set the font style to bold or italic. Content editing uses the native text input system, enabling all the text manipulation features and gestures common on Android.

License

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

Enabling and Disabling Content Editing

If your license includes the content editing feature, it’s enabled by default, and the Content Editor item will show up on the main action bar. If you want to disable it, use PdfActivityConfiguration.Builder:

val config =
    PdfActivityConfiguration.Builder(context)
        .disableContentEditing()
        .build()
final PdfActivityConfiguration config =
    new PdfActivityConfiguration.Builder(context)
        .disableContentEditing()
        .build();

You can also use PdfConfiguration.Builder:

val config =
    PdfConfiguration.Builder()
        .disableContentEditing()
        .build()
PdfConfiguration config =
    new PdfConfiguration.Builder()
        .disableContentEditing()
        .build();

Both will remove the Content Editor item from the action bar.

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. On the main action bar, tap the Content Editor button.

  2. Tap within a text box on the page.

  3. Add or delete content in the text box.

  4. On the keyboard accessory toolbar, change the text color, the font type, or the font size, or set the font style to bold or italic.

  5. On the content editing toolbar, click the Save button to save your changes.

Paragraph Editing

Prior to version 2024.1, you could only edit single lines of text. Now, we support editing of whole paragraphs. Although the concept of paragraphs doesn’t exist in the PDF format, our editing engine recognizes lines that belong together and groups them into paragraphs, which can be edited as an entity. This new feature includes the ability to:

  • Create new paragraphs and delete existing ones.

  • Copy/paste text and paragraphs.

  • Resize and reposition paragraphs using drag and drop.

  • Change the text alignment of a paragraph (left/center/right/justified).

Triggering the Content Editing Mode Programmatically

You can enter content editing mode in your code by calling PdfFragment#enterContentEditingMode:

pdfFragment.enterContentEditingMode()
getPdfFragment(). enterContentEditingMode();

Supported Text Editing Functionalities

The following text editing functionalities are supported:

  • Adding or changing the text colors and font types supported by PSPDFKit.

  • Adding or changing the text font size.

  • Adding or changing the text to bold and italic.

  • Undo/redo

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

  • Editing the text using a hardware keyboard paired with your device.

Limitations

Text editing currently comes with the following limitations:

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

  • Copying and pasting a paragraph with all its style information only works within the content editing session where the copy was made, and only within the same document. However, the plain text information can be pasted outside of the session or document.