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,PdfEditorTool,PdfEditorOpenOptions,PdfEditor - Customization —
PdfEditorAction,PdfEditorMenuItem,PdfEditorColor,PdfEditorMarkupStyle,PdfEditorInkStyle,PdfEditorColors,PdfEditorLocalization,PdfEditorConfiguration - Document API —
PdfRect,PdfPoint,PdfLayerKind,PdfShape,PdfMetadataKey,PdfFontFamily,PdfZOrder,PdfMarkupKind,PdfImageKind,PdfFormFieldKind,PdfTextResult,PdfLayer,PdfSearchMatch,PdfFormField,PdfDocumentError,PdfDocument - SDK, licensing and callbacks —
PdfEditorLicense
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 PdfEditorOpenOptionspath
path?: stringA PDF on disk. Give this or asset.
asset
asset?: stringA 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?: stringHonoured on Android. On iOS the editor asks for the password in its own UI instead.
mode
mode?: PdfEditorModetool
tool?: PdfEditorToolconfiguration
configuration?: PdfEditorConfigurationinPlace
inPlace?: booleanOverwrite 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 = stringA 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 PdfEditorColorsThe 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?: PdfEditorColorButtons, the armed tool, Done, the selection (unless selectionColor is set).
onAccent
onAccent?: PdfEditorColorText and glyphs drawn on the accent.
canvasBackground
canvasBackground?: PdfEditorColorBehind and around the pages.
toolbarBackground
toolbarBackground?: PdfEditorColorThe header, the mode toolbar, the property bars and the floating pills.
toolbarForeground
toolbarForeground?: PdfEditorColorIcons and labels on those bars.
secondaryForeground
secondaryForeground?: PdfEditorColorCaptions, hints, inactive labels.
panelBackground
panelBackground?: PdfEditorColorThe editor's sheets, dialogs and (Android) menus.
destructive
destructive?: PdfEditorColorDelete and other destructive actions.
PdfEditorLocalization
export interface PdfEditorLocalizationSee PdfEditorConfiguration.localization.
language
language?: stringA 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 PdfEditorConfigurationmodes
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?: numberThe zoom range, where 1 is the page fitted to the screen. Clamped to 0.5–3. 1 and 1 turn zoom off.
maxZoom
maxZoom?: numberhaptics
haptics?: booleanTaps, snaps and alignment guides.
showsUsageHints
showsUsageHints?: booleanOne-time hints such as "Drag across text to highlight it".
localization
localization?: PdfEditorLocalizationThe 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?: stringiOS 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?: stringshowsStandardFonts
showsStandardFonts?: booleanWhich 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?: booleanshowsDeviceFonts
showsDeviceFonts?: booleanallowsFontImport
allowsFontImport?: booleannewTextFont
newTextFont?: stringA font file (path) that every new text box is set in. Size and colour still follow the surrounding text.
selectionColor
selectionColor?: PdfEditorColorSelection box, handles, rotate knob, caret, text-selection band, page guide. selectionColorDark is Android only.
selectionColorDark
selectionColorDark?: PdfEditorColorhandleFillColor
handleFillColor?: PdfEditorColorhandleShape
handleShape?: '' | '' | ''handleScale
handleScale?: numberHandle and knob size, clamped to 0.75–1.5.
selectionBorderWidth
selectionBorderWidth?: numberThe selection outline, in points, clamped to 1–3.
searchHighlightColor
searchHighlightColor?: PdfEditorColorThe wash over every search match, and over the current one. The translucency stays the editor's.
searchCurrentHighlightColor
searchCurrentHighlightColor?: PdfEditorColortoolDefaults
toolDefaults?:First-use styles. Once a user picks their own colour, theirs wins on that device.
colors
colors?: PdfEditorColorsThe editor's own colours. colorsDark overrides colors field by field in the dark scheme.
colorsDark
colorsDark?: PdfEditorColorsactionTitles
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?: booleanfontSizes
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?: booleanThe floating pills along the bottom.
showsPageNavigator
showsPageNavigator?: booleanshowsZoomControls
showsZoomControls?: booleanDocument 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 PdfLayerOne layer of a page, as data. Read again after a change — a layer's properties are a snapshot.
page
page: numberid
id: numberStable while other layers change; a layer that comes back from undo gets a new one.
kind
kind: PdfLayerKindx
x: numberrotation
rotation: numberDegrees, clockwise as seen.
opacity
opacity: numberzIndex
zIndex: numberlink
link?: stringtext
text?: stringfontName
fontName?: stringfontSize
fontSize?: numberbold
bold?: booleansymbolic
symbolic?: booleanSet entirely in symbol fonts — an ornament or a check box drawn as letters. Not language.
textColor
textColor?: stringpixelWidth
pixelWidth?: numbernote
note?: stringshape
shape?: PdfShapefillColor
fillColor?: stringPdfSearchMatch
interface PdfSearchMatch { page: number; rects: PdfRect[] }PdfFormField
export interface PdfFormField extends PdfRectA form field of the document.
name
name: stringkind
kind: stringtext, checkbox, radio, combobox, listbox, button, signature or unknown.
page
page: numbervalue
value: stringchecked
checked?: booleanexportValue
exportValue?: stringoptions
options: string[]readOnly
readOnly: booleanPdfDocumentError
export class PdfDocumentError extends ErrorWhy 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 PdfDocumentA 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
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 PdfEditorLicenseThe license verdict, as the native SDK decided it.
status
status: stringvalid, unlicensed, invalid, expired, wrongApp, wrongPlatform, versionNotCovered, …
isLicensed
isLicensed: booleanreason
reason: stringA sentence saying why — log it in a debug build when isLicensed is false.
licensee
licensee: stringplan
plan: stringexpires
expires: string | nullidentity
identity: stringThe bundle identifier / package name the key was checked against.
licenseId
licenseId: stringThe 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: booleanAn 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: booleanOnline keys: the vendor marked the payment overdue. It still works.
message
message: stringOnline keys: the vendor's note to the developer.