Skip to content

PDF-SDK 2.4.1 is out.See what’s new

PDF-SDK
Skip to Content
Docs

React Native API reference

Generated from the package's TypeScript sources. For a guided introduction — adding the package, opening the editor, customizing it — start with the React Native guide.

Package @pdfsdk/react-native-pdf-editor: 29 public types and 169 members, generated from the SDK's sources at build time, so this page cannot drift from them.

The editor

PdfEditorMode

export type PdfEditorMode = '' | '' | '' | '' | '' | '' | ''

Which editor the document opens in.

PdfEditorTool

export type PdfEditorTool = | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | ''

A tool to arm as the editor opens, hide, rename or reorder.

PdfEditorOpenOptions

export interface PdfEditorOpenOptions

path

path?: string

A PDF on disk. Give this or asset.

asset

asset?: string

A PDF bundled with the app — in the iOS app bundle, or under Android's assets/ — by name, e.g. 'form.pdf'. It is copied to a temporary file and opened from there, so the bundled original is never written.

password

password?: string

Honoured on Android. On iOS the editor asks for the password in its own UI instead.

mode

mode?: PdfEditorMode

tool

tool?: PdfEditorTool

configuration

configuration?: PdfEditorConfiguration

inPlace

inPlace?: boolean

Overwrite path with the edit (and resolve with path). Otherwise the result is a new temporary file.

onDocumentReady

onDocumentReady?: (document: PdfDocument)

Called once the document is open, with a PdfDocument for the document the editor is SHOWING: changes appear on screen at once and the user can undo them. It stops working when the editor closes (calls then reject with notFound); close() on it does nothing — the editor owns it.

PdfEditor

export const PdfEditor =

Opens the native editor, full screen, and waits for the user to finish.

setLicenseKey

setLicenseKey: (key: string): Promise<PdfEditorLicense>

Set your PDF-SDK license key, once, before the first open — typically at app start.

license

license: (): Promise<PdfEditorLicense>

The current license verdict.

refreshLicense

refreshLicense: (): Promise<PdfEditorLicense>

Online licenses: ask the license server now and resolve to the verdict afterwards (the native SDK also checks at launch and when the app returns to the foreground). Offline keys resolve at once.

open

open: (options: PdfEditorOpenOptions): Promise<string | null>

Present the editor over options.path (or the bundled options.asset) and resolve when the user leaves it: with the path of the edited PDF, or null if they closed without saving. A path rather than the bytes, because a real document is far larger than a bridge call — read it with your file-system library if you want the bytes.

Rejects with a code (bad_args, not_found, already_open, no_activity, unsupported, write_failed) when the editor can't open. A user simply closing the editor is not an error.

nativeVersion

nativeVersion: (): Promise<string>

The native SDK's own version — log it next to your build number for crash reports.

isSupported

isSupported: (): Promise<boolean>

Whether the native engine loaded on this device (false only for an ABI the app shipped without).

Customization

PdfEditorAction

export type PdfEditorAction = | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | '' | ''

A sub-tool: a control that appears once something is selected, or on a page in the page panel.

PdfEditorMenuItem

export type PdfEditorMenuItem = | '' | '' | '' | '' | '' | '' | '' | ''

The ⋮ (More) menu's items. flattenDocument exists on Android only and is ignored on iOS.

PdfEditorColor

export type PdfEditorColor = string

A colour as #RRGGBB (or #RGB). Alpha is ignored: these colours are drawn opaque.

PdfEditorMarkupStyle

interface PdfEditorMarkupStyle { color: PdfEditorColor;  opacity?: number }

PdfEditorInkStyle

interface PdfEditorInkStyle { color: PdfEditorColor;  width?: number;  opacity?: number }

PdfEditorColors

export interface PdfEditorColors

The editor's own colours. Each one left out keeps the editor's. Give toolbarBackground and no toolbarForeground, and the editor picks white or near-black ink for it.

accent

accent?: PdfEditorColor

Buttons, the armed tool, Done, the selection (unless selectionColor is set).

onAccent

onAccent?: PdfEditorColor

Text and glyphs drawn on the accent.

canvasBackground

canvasBackground?: PdfEditorColor

Behind and around the pages.

toolbarBackground

toolbarBackground?: PdfEditorColor

The header, the mode toolbar, the property bars and the floating pills.

toolbarForeground

toolbarForeground?: PdfEditorColor

Icons and labels on those bars.

secondaryForeground

secondaryForeground?: PdfEditorColor

Captions, hints, inactive labels.

panelBackground

panelBackground?: PdfEditorColor

The editor's sheets, dialogs and (Android) menus.

destructive

destructive?: PdfEditorColor

Delete and other destructive actions.

PdfEditorLocalization

export interface PdfEditorLocalization

See PdfEditorConfiguration.localization.

language

language?: string

A BCP-47 tag ("hi", "ar", "pt-BR"); omitted = the app's language. Also picks the native SDK's own resources.

strings

strings?: Record<string, string>

Key → text.

layoutDirection

layoutDirection?: '' | '' | ''

automatic (the default) follows language.

PdfEditorConfiguration

export interface PdfEditorConfiguration

modes

modes?: PdfEditorMode[]

The modes the Tools sheet offers, in this order. One mode hides the mode picker.

hiddenTools

hiddenTools?: PdfEditorTool[]

Tools removed from every mode that carries them.

hiddenMenuItems

hiddenMenuItems?: PdfEditorMenuItem[]

Items removed from the ⋮ menu.

colorScheme

colorScheme?: '' | '' | ''

Light, dark, or the system's (the default).

minZoom

minZoom?: number

The zoom range, where 1 is the page fitted to the screen. Clamped to 0.5–3. 1 and 1 turn zoom off.

maxZoom

maxZoom?: number

haptics

haptics?: boolean

Taps, snaps and alignment guides.

showsUsageHints

showsUsageHints?: boolean

One-time hints such as "Drag across text to highlight it".

localization

localization?: PdfEditorLocalization

The editor's language: text for its words by key (the same keys on every platform; the list with the English text is docs/localization/strings.json). Untranslated keys stay English. Placeholders are positional, "Page {1} of {2}". toolTitles, modeTitles and menuItemTitles win over it.

toolTitles

toolTitles?: Partial<Record<PdfEditorTool, string>>

Your names for tools (everywhere they appear), modes and ⋮ items.

modeTitles

modeTitles?: Partial<Record<PdfEditorMode, string>>

menuItemTitles

menuItemTitles?: Partial<Record<PdfEditorMenuItem, string>>

toolOrder

toolOrder?: Partial<Record<PdfEditorMode, PdfEditorTool[]>>

Listed tools first, in your order, then the rest. A tool can only be reordered within a mode it is in.

menuOrder

menuOrder?: PdfEditorMenuItem[]

Listed ⋮ items first, then the rest.

interfaceFontFamily

interfaceFontFamily?: string

iOS only*: the editor's own text in this font family.

fonts

fonts?: string[]

Font files (paths on disk) listed first in the text font picker, under fontsTitle.

fontsTitle

fontsTitle?: string

showsStandardFonts

showsStandardFonts?: boolean

Which other sections the font picker shows: the standard PDF fonts (Helvetica, Times, Courier), the document's embedded fonts, the device's fonts, and the import button with the fonts imported before.

showsDocumentFonts

showsDocumentFonts?: boolean

showsDeviceFonts

showsDeviceFonts?: boolean

allowsFontImport

allowsFontImport?: boolean

newTextFont

newTextFont?: string

A font file (path) that every new text box is set in. Size and colour still follow the surrounding text.

selectionColor

selectionColor?: PdfEditorColor

Selection box, handles, rotate knob, caret, text-selection band, page guide. selectionColorDark is Android only.

selectionColorDark

selectionColorDark?: PdfEditorColor

handleFillColor

handleFillColor?: PdfEditorColor

handleShape

handleShape?: '' | '' | ''

handleScale

handleScale?: number

Handle and knob size, clamped to 0.75–1.5.

selectionBorderWidth

selectionBorderWidth?: number

The selection outline, in points, clamped to 1–3.

searchHighlightColor

searchHighlightColor?: PdfEditorColor

The wash over every search match, and over the current one. The translucency stays the editor's.

searchCurrentHighlightColor

searchCurrentHighlightColor?: PdfEditorColor

toolDefaults

toolDefaults?:

First-use styles. Once a user picks their own colour, theirs wins on that device.

colors

colors?: PdfEditorColors

The editor's own colours. colorsDark overrides colors field by field in the dark scheme.

colorsDark

colorsDark?: PdfEditorColors

actionTitles

actionTitles?: Partial<Record<PdfEditorAction, string>>

Your names for the sub-tools — the property bar, the menu over the selection, the page actions.

hiddenActions

hiddenActions?: PdfEditorAction[]

Sub-tools removed wherever they appear.

actionOrder

actionOrder?: PdfEditorAction[]

Listed sub-tools first, in this order; the rest keep the editor's order.

markupColors

markupColors?: PdfEditorColor[]

The Annotate colour row, the Draw ink colours (Android, and iOS on Mac), the signature pad's colours.

inkColors

inkColors?: PdfEditorColor[]

signatureColors

signatureColors?: PdfEditorColor[]

stamps

stamps?: Array<{ text: string; color?: PdfEditorColor } | { date: true; color?: PdfEditorColor }>

The Stamp tool's presets — { text, color }, or { date: true, color } for today's date.

allowsCustomStamp

allowsCustomStamp?: boolean

fontSizes

fontSizes?: number[]

The font-size list, in points.

signatureMethods

signatureMethods?: Array<'' | '' | '' | ''>

The signature pad's tabs, in order.

signaturePlacement

signaturePlacement?: '' | '' | '' | '' | ''

Where the e-Sign tab's Placement picker starts (the user can still change it). Default 'bottomRight'.

showsUndoRedo

showsUndoRedo?: boolean

The floating pills along the bottom.

showsPageNavigator

showsPageNavigator?: boolean

showsZoomControls

showsZoomControls?: boolean

Document API

PdfRect

interface PdfRect { x: number; y: number; width: number; height: number }

A rectangle in page points, top-left origin.

PdfPoint

interface PdfPoint { x: number; y: number }

PdfLayerKind

export type PdfLayerKind = '' | '' | '' | '' | '' | '' | '' | ''

PdfShape

export type PdfShape = '' | '' | '' | ''

PdfMetadataKey

export type PdfMetadataKey = '' | '' | '' | '' | '' | ''

PdfFontFamily

export type PdfFontFamily = '' | '' | ''

The built-in families every PDF reader has.

PdfZOrder

export type PdfZOrder = '' | '' | '' | ''

PdfMarkupKind

export type PdfMarkupKind = '' | '' | ''

PdfImageKind

export type PdfImageKind = '' | '' | '' | ''

What an image layer is to the editor: a signature, a hand drawing and a stamp are images it knows by kind.

PdfFormFieldKind

export type PdfFormFieldKind = '' | '' | '' | '' | ''

PdfTextResult

export type PdfTextResult = '' | ''

How a text replacement went: it fits where the old text was, or it is taller (it may run into what is below).

PdfLayer

export interface PdfLayer

One layer of a page, as data. Read again after a change — a layer's properties are a snapshot.

page

page: number

id

id: number

Stable while other layers change; a layer that comes back from undo gets a new one.

kind

kind: PdfLayerKind

x

x: number

rotation

rotation: number

Degrees, clockwise as seen.

opacity

opacity: number

zIndex

zIndex: number
link?: string

text

text?: string

fontName

fontName?: string

fontSize

fontSize?: number

bold

bold?: boolean

symbolic

symbolic?: boolean

Set entirely in symbol fonts — an ornament or a check box drawn as letters. Not language.

textColor

textColor?: string

pixelWidth

pixelWidth?: number

note

note?: string

shape

shape?: PdfShape

fillColor

fillColor?: string

PdfSearchMatch

interface PdfSearchMatch { page: number; rects: PdfRect[] }

PdfFormField

export interface PdfFormField extends PdfRect

A form field of the document.

name

name: string

kind

kind: string

text, checkbox, radio, combobox, listbox, button, signature or unknown.

page

page: number

value

value: string

checked

checked?: boolean

exportValue

exportValue?: string

options

options: string[]

readOnly

readOnly: boolean

PdfDocumentError

export class PdfDocumentError extends Error

Why a document call failed. code: cannotOpen, notFound (read the layers again), unsupportedGlyphs (no font can draw the text — nothing changed), failed (the engine refused), badArguments.

PdfDocument

export class PdfDocument

A PDF opened from code, with no UI — a templating, form-filling or batch job. close() it when done.

open

static open: (base64: string, password?: string)

Open a PDF (base64) headless, with the system's fonts for every script. (Set by index.ts, over the native module.)

close

async close(): Promise<void>

Free the native document. Calls after this fail with notFound. The editor's own document is left to the editor.

pageCount

pageCount(): Promise<number>

pageSize

pageSize(page: number): Promise<{ width: number; height: number }>

The page's size in points (as displayed, i.e. after its rotation).

save

save(): Promise<string>

The edited PDF, base64.

metadata

async metadata(key: PdfMetadataKey): Promise<string>

setMetadata

setMetadata(key: PdfMetadataKey, value: string): Promise<void>

Written into the file save produces.

text

text(page: number): Promise<string>

The page's plain text.

search

search(
    query: string,
    options: { caseSensitive?: boolean } = {},
): Promise<PdfSearchMatch[]>

Every match of query in the document.

renderPage

renderPage(
    page: number,
    width: number,
    height: number,
): Promise<string | null>

The page drawn into a width×height PNG (base64) — a thumbnail, a preview.

canUndo

canUndo(): Promise<boolean>

canRedo

canRedo(): Promise<boolean>

undo

undo(): Promise<boolean>

Undo the last change. A layer that comes back gets a NEW id — read the layers again.

redo

redo(): Promise<boolean>

insertBlankPage

insertBlankPage(
    index: number,
    size: { width?: number; height?: number } = {},
): Promise<void>

Insert a blank page at index (a zero size takes the neighbouring page's).

deletePage

deletePage(index: number): Promise<void>

movePage

movePage(from: number, to: number): Promise<void>

duplicatePage

duplicatePage(index: number): Promise<void>

rotatePage

rotatePage(index: number, clockwise = true): Promise<void>

importPages

importPages(
    base64: string,
    options: { password?: string; pages?: number[]; index?: number } = {},
): Promise<void>

Copy pages (all when left out) of another PDF (base64) in at index (the end when left out). Read layer ids again.

extractPages

extractPages(pages: number[]): Promise<string>

pages of this document as a new PDF, base64.

layers

layers(page: number): Promise<PdfLayer[]>

Every layer of the page, in reading order for a page read the first time.

textBlocks

textBlocks(page: number): Promise<PdfLayer[]>

layer

layer(layer: PdfLayer): Promise<PdfLayer>

The layer as it is now.

image

image(layer: PdfLayer): Promise<string | null>

The picture of an image layer as PNG (base64), at its own pixel size.

sound

sound(layer: PdfLayer): Promise<string | null>

The audio of a sound layer, base64.

setText

setText(
    layer: PdfLayer,
    text: string,
    options: { shrinkToFit?: boolean } = {},
): Promise<PdfTextResult>

Replace a text layer's text, keeping its font, size, colour and position. Any script works: the system's fonts fill in what the layer's font lacks. shrinkToFit lowers the size (to half at most) until it fits.

setFontSize

setFontSize(layer: PdfLayer, points: number): Promise<void>

setFont

setFont(
    layer: PdfLayer,
    family: PdfFontFamily,
    style: { bold?: boolean; italic?: boolean } = {},
): Promise<void>

setFontData

setFontData(
    layer: PdfLayer,
    base64: string,
    name: string,
): Promise<void>

Embed a font of your own (TTF/OTF, base64) and set the layer in it.

setTextStyle

setTextStyle(
    layer: PdfLayer,
    style: { bold?: boolean; italic?: boolean },
): Promise<void>

Bold / italic of the current family; one left out stays as it is.

setUnderline

setUnderline(layer: PdfLayer, on: boolean): Promise<void>

setStrikethrough

setStrikethrough(layer: PdfLayer, on: boolean): Promise<void>

setFillColor

setFillColor(layer: PdfLayer, color: string): Promise<void>

Text colour, or a shape's fill.

setStrokeColor

setStrokeColor(layer: PdfLayer, color: string): Promise<void>

setStrokeWidth

setStrokeWidth(layer: PdfLayer, points: number): Promise<void>

setOpacity

setOpacity(layer: PdfLayer, opacity: number): Promise<void>

setFrame

setFrame(layer: PdfLayer, rect: PdfRect): Promise<void>

Move and resize (text scales uniformly).

setRotation

setRotation(layer: PdfLayer, degrees: number): Promise<void>

Degrees, clockwise as seen.

setZOrder

setZOrder(layer: PdfLayer, order: PdfZOrder): Promise<void>
setLink(layer: PdfLayer, url: string | null): Promise<void>

null removes the link.

setSound

setSound(layer: PdfLayer, base64: string, name: string): Promise<void>

replaceImage

replaceImage(layer: PdfLayer, base64: string): Promise<void>

Swap an image layer's picture (PNG or JPEG, base64), keeping its frame and kind.

setMarkup

setMarkup(
    layer: PdfLayer,
    kind: PdfMarkupKind,
    color: string,
): Promise<void>

Mark a whole text layer up.

removeMarkup

removeMarkup(layer: PdfLayer): Promise<void>

delete

delete(layer: PdfLayer): Promise<void>

duplicate

duplicate(
    layer: PdfLayer,
    offset: { dx?: number; dy?: number } = {},
): Promise<PdfLayer>

A copy offset by (dx, dy) points.

copy

copy(
    layer: PdfLayer,
    toPage: number,
    x: number,
    y: number,
): Promise<PdfLayer>

A copy on another page, its top-left at (x, y) there.

addText

addText(
    text: string,
    page: number,
    x: number,
    y: number,
    options: { fontSize?: number; color?: string; family?: PdfFontFamily } = {},
): Promise<PdfLayer>

A text layer with its top-left at (x, y).

addImage

addImage(
    base64: string,
    page: number,
    rect: PdfRect,
    options: { kind?: PdfImageKind; note?: string } = {},
): Promise<PdfLayer>

An image layer (PNG or JPEG, base64) filling rect. A signature, a drawing or a stamp is an image of that kind.

addShape

addShape(
    shape: PdfShape,
    page: number,
    from: PdfPoint,
    to: PdfPoint,
    options: { fill?: string; stroke?: string; strokeWidth?: number } = {},
): Promise<PdfLayer>

A rectangle or ellipse filling the rect from from to to, or a line / arrow from from to to.

markupText

markupText(
    page: number,
    from: PdfPoint,
    to: PdfPoint,
    options: { kind?: PdfMarkupKind; color?: string } = {},
): Promise<void>

Mark up the text between two points of the page, as a drag with the tool would.

formFields

formFields(): Promise<PdfFormField[]>

setFormValue

setFormValue(field: string, value: string): Promise<void>

Fill a field: its text, an option's label, "true"/"false" for a check box, or the radio button's export value.

fillForm

fillForm(values: Record<string, string>): Promise<void>

Fill several fields at once.

addFormField

addFormField(
    kind: PdfFormFieldKind,
    page: number,
    rect: PdfRect,
    options: { name?: string; options?: string[] } = {},
): Promise<string>

A new field; resolves with its name (name, or one the editor made up). Radios that share a name are one set.

deleteFormField

deleteFormField(name: string): Promise<void>

Remove every widget called name (a whole radio set).

resetForm

resetForm(): Promise<void>

flattenForm

flattenForm(): Promise<void>

Bake the fields into the pages (their values stay, they stop being editable).

SDK, licensing and callbacks

PdfEditorLicense

export interface PdfEditorLicense

The license verdict, as the native SDK decided it.

status

status: string

valid, unlicensed, invalid, expired, wrongApp, wrongPlatform, versionNotCovered, …

isLicensed

isLicensed: boolean

reason

reason: string

A sentence saying why — log it in a debug build when isLicensed is false.

licensee

licensee: string

plan

plan: string

expires

expires: string | null

identity

identity: string

The bundle identifier / package name the key was checked against.

licenseId

licenseId: string

The license id (lic_…) — quote it when you renew.

updatesUntil

updatesUntil: string | null

"Updates until": the key covers SDK releases published on or before this date (versionNotCovered when this release is newer). Null when the key has no such limit.

isOnline

isOnline: boolean

An online key: confirmed with the vendor's license server, which can suspend (status: 'suspended') and resume it. verificationRequired means not confirmed yet — the native SDK does that on its own.

paymentDue

paymentDue: boolean

Online keys: the vendor marked the payment overdue. It still works.

message

message: string

Online keys: the vendor's note to the developer.