Skip to content

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

PDF-SDK
Skip to Content
Docs

Flutter API reference

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

Package pdf_editor (import 'package:pdf_editor/pdf_editor.dart';): 33 public types and 338 members, generated from the SDK's sources at build time, so this page cannot drift from them.

The editor

PdfEditorMode

enum PdfEditorMode

Which editor the document opens in.

The seven modes are identical on both platforms, but three of them are SPELLED differently in the native SDKs (.contentEditor/EDIT, .fillSign/FILL_AND_SIGN, .form/FORMS).

viewer

PdfEditorMode.viewer

Read-only. No toolbar, no selection, no undo — just the document.

edit

PdfEditorMode.edit

Content editing: select, move, restyle and retype what is already on the page.

forms

PdfEditorMode.forms

AcroForm authoring: place and configure text fields, check boxes, radios, lists, dropdowns.

annotate

PdfEditorMode.annotate

Text markup: highlight, underline, strikeout, squiggly.

fillAndSign

PdfEditorMode.fillAndSign

Signature, text and stamp placement.

insert

PdfEditorMode.insert

Add pages, images, notes and text boxes.

draw

PdfEditorMode.draw

Freehand ink and shapes.

PdfEditorTool

enum PdfEditorTool

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

addText

PdfEditorTool.addText

image

PdfEditorTool.image
PdfEditorTool.link

insertPage

PdfEditorTool.insertPage

multiSelect

PdfEditorTool.multiSelect

highlight

PdfEditorTool.highlight

underline

PdfEditorTool.underline

strikeout

PdfEditorTool.strikeout

squiggly

PdfEditorTool.squiggly

signature

PdfEditorTool.signature

stamp

PdfEditorTool.stamp

note

PdfEditorTool.note

draw

PdfEditorTool.draw

shapeRectangle

PdfEditorTool.shapeRectangle

shapeEllipse

PdfEditorTool.shapeEllipse

shapeLine

PdfEditorTool.shapeLine

shapeArrow

PdfEditorTool.shapeArrow

formTextField

PdfEditorTool.formTextField

formCheckBox

PdfEditorTool.formCheckBox

formRadioButton

PdfEditorTool.formRadioButton

formListBox

PdfEditorTool.formListBox

formDropdown

PdfEditorTool.formDropdown

PdfEditor

abstract final class PdfEditor

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

setLicenseKey

static Future<PdfEditorLicense> setLicenseKey(String key) async

Set your PDF-SDK license key, once, before the first open — typically in main().

The key is issued for your app's bundle identifier (iOS) and package name (Android) and is checked offline inside the SDK. Without a valid key the editor opens nothing and says why on screen.

license

static Future<PdfEditorLicense> license() async

The current license verdict.

refreshLicense

static Future<PdfEditorLicense> refreshLicense() async

Online licenses: ask the vendor's license server now and complete with the verdict afterwards (the native SDK also checks by itself at launch and when the app returns to the foreground). Offline keys complete at once.

open

static Future<String?> open(
    {
      required String path,
      String? password,
      PdfEditorMode? mode,
      PdfEditorTool? tool,
      PdfEditorConfiguration? configuration,
      bool inPlace = false,
      void Function(PdfDocument document)? onDocumentReady,
    }
) async

Present the editor over path and complete when the user leaves it.

Returns the path of the edited PDF, or null if the user closed the editor without saving.

A path rather than the bytes, deliberately. The native SDKs hand back the whole document, and a real document is tens or hundreds of megabytes: on Android that cannot cross an Intent (Binder's ~1 MB transaction limit), and on both platforms it would be copied again through the method channel. The plugin writes the result to a file and returns where — read it with File(result).readAsBytes() if you do want the bytes.

With inPlace the edit overwrites path and that same path is returned. Otherwise the result is written in the system temporary directory and is yours to move or delete.

password is honoured on Android. On iOS it is ignored: that shell prompts for the password in its own UI instead, so an encrypted document still opens — the user is simply asked.

Throws a PlatformException whose code is bad_args, not_found, already_open, no_activity, write_failed (the edited file couldn't be written) or, on Android, unsupported (no engine for this device's ABI). A user closing the editor is not an error: that returns null.

onDocumentReady is 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 throw notFound); don't PdfDocument.close it — the editor owns it.

nativeVersion

static Future<String> nativeVersion() async

The native SDK's own version, which is not the host app's and not this package's.

Worth logging next to your build stamp: a crash report shows the HOST's version, so without this there is nothing in the report that identifies which engine was running.

isSupported

static Future<bool> isSupported() async

Whether the native engine loaded. False when the app shipped without a slice for this ABI.

You do not have to check: open throws unsupported rather than failing silently. It is here so a host CAN route around the editor entirely — hide the Edit button — instead of offering a dead end.

Customization

PdfEditorAction

enum PdfEditorAction

A sub-tool: a control that appears once something is selected (the property bar, the menu over the selection) or on a page in the page panel. Rename, hide and reorder them with PdfEditorConfiguration.actionTitles, hiddenActions and actionOrder.

multiSelect

PdfEditorAction.multiSelect

editText

PdfEditorAction.editText

textColor

PdfEditorAction.textColor

font

PdfEditorAction.font

textStyle

PdfEditorAction.textStyle

fontSize

PdfEditorAction.fontSize

opacity

PdfEditorAction.opacity

strokeColor

PdfEditorAction.strokeColor

fillColor

PdfEditorAction.fillColor

strokeWidth

PdfEditorAction.strokeWidth

editNote

PdfEditorAction.editNote

noteColor

PdfEditorAction.noteColor

resign

PdfEditorAction.resign

replaceImage

PdfEditorAction.replaceImage

crop

PdfEditorAction.crop

playSound

PdfEditorAction.playSound
PdfEditorAction.link

cut

PdfEditorAction.cut

copy

PdfEditorAction.copy

duplicate

PdfEditorAction.duplicate

delete

PdfEditorAction.delete

formFill

PdfEditorAction.formFill

formOptions

PdfEditorAction.formOptions

formRadioGroup

PdfEditorAction.formRadioGroup

formColors

PdfEditorAction.formColors

formBorderWidth

PdfEditorAction.formBorderWidth

paste

PdfEditorAction.paste

rotatePageLeft

PdfEditorAction.rotatePageLeft

rotatePageRight

PdfEditorAction.rotatePageRight

duplicatePage

PdfEditorAction.duplicatePage

insertBlankPage

PdfEditorAction.insertBlankPage

deletePage

PdfEditorAction.deletePage

PdfEditorSignatureMethod

enum PdfEditorSignatureMethod

The signature pad's tabs, for PdfEditorConfiguration.signatureMethods.

draw

PdfEditorSignatureMethod.draw

type

PdfEditorSignatureMethod.type

image

PdfEditorSignatureMethod.image

eSign

PdfEditorSignatureMethod.eSign

PdfEditorSignaturePlacement

enum PdfEditorSignaturePlacement

Where the e-Sign tab's Placement picker starts, for PdfEditorConfiguration.signaturePlacement.

bottomRight

PdfEditorSignaturePlacement.bottomRight

bottomLeft

PdfEditorSignaturePlacement.bottomLeft

topRight

PdfEditorSignaturePlacement.topRight

topLeft

PdfEditorSignaturePlacement.topLeft

invisible

PdfEditorSignaturePlacement.invisible

PdfEditorStamp

class PdfEditorStamp

A rubber stamp for PdfEditorConfiguration.stamps. PdfEditorStamp.date reads the day it's placed.

PdfEditorStamp

const PdfEditorStamp(this.text, this.color) : isDate = false

PdfEditorStamp.date

const PdfEditorStamp.date(this.color) : text = '', isDate = true

text

final String text

color

final Color color

isDate

final bool isDate

PdfEditorMenuItem

enum PdfEditorMenuItem

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

search

PdfEditorMenuItem.search

managePages

PdfEditorMenuItem.managePages

sharePdf

PdfEditorMenuItem.sharePdf

print

PdfEditorMenuItem.print

flattenAndShare

PdfEditorMenuItem.flattenAndShare

flattenDocument

PdfEditorMenuItem.flattenDocument

resetForm

PdfEditorMenuItem.resetForm

resetToOriginal

PdfEditorMenuItem.resetToOriginal

PdfEditorColorScheme

enum PdfEditorColorScheme

The editor's appearance.

system

PdfEditorColorScheme.system

light

PdfEditorColorScheme.light

dark

PdfEditorColorScheme.dark

PdfEditorLayoutDirection

enum PdfEditorLayoutDirection

The editor's reading direction. automatic follows PdfEditorLocalization.language.

automatic

PdfEditorLayoutDirection.automatic

ltr

PdfEditorLayoutDirection.ltr

rtl

PdfEditorLayoutDirection.rtl

PdfEditorLocalization

class PdfEditorLocalization

The editor's language: text for its words by key (the keys are the same 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.

PdfEditorLocalization

const PdfEditorLocalization(
    {
      this.language,
      this.strings = const {},
      this.layoutDirection = PdfEditorLayoutDirection.automatic,
    }
)

language

final String? language

A BCP-47 tag ("hi", "ar", "pt-BR"); null = the app's language. Also picks the native SDK's own resources in that language (<language>.lproj/PDFEditor.strings on iOS, values-<language> on Android).

strings

final Map<String, String> strings

Key → text.

layoutDirection

final PdfEditorLayoutDirection layoutDirection

toMap

Map<String, Object?> toMap()

PdfEditorHandleShape

enum PdfEditorHandleShape

The shape of the selection handles.

roundedSquare

PdfEditorHandleShape.roundedSquare

circle

PdfEditorHandleShape.circle

square

PdfEditorHandleShape.square

PdfEditorMarkupStyle

class PdfEditorMarkupStyle

A text-markup tool's first-use style. opacity is clamped to 0.1–1.

PdfEditorMarkupStyle

const PdfEditorMarkupStyle({required this.color, this.opacity = 1})

color

final Color color

opacity

final double opacity

PdfEditorInkStyle

class PdfEditorInkStyle

width is clamped to 1–30 points, opacity to 0.1–1.

PdfEditorInkStyle

const PdfEditorInkStyle(
    {
      required this.color,
      this.width = 5,
      this.opacity = 1,
    }
)

color

final Color color

width

final double width

opacity

final double opacity

PdfEditorColors

class PdfEditorColors

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

PdfEditorColors

const PdfEditorColors(
    {
      this.accent,
      this.onAccent,
      this.canvasBackground,
      this.toolbarBackground,
      this.toolbarForeground,
      this.secondaryForeground,
      this.panelBackground,
      this.destructive,
    }
)

accent

final Color? accent

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

onAccent

final Color? onAccent

Text and glyphs drawn on the accent.

canvasBackground

final Color? canvasBackground

Behind and around the pages.

toolbarBackground

final Color? toolbarBackground

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

toolbarForeground

final Color? toolbarForeground

Icons and labels on those bars.

secondaryForeground

final Color? secondaryForeground

Captions, hints, inactive labels.

panelBackground

final Color? panelBackground

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

destructive

final Color? destructive

Delete and other destructive actions.

PdfEditorToolDefaults

class PdfEditorToolDefaults

Once a user picks their own colour, theirs wins on that device.

PdfEditorToolDefaults

const PdfEditorToolDefaults(
    {
      this.highlight,
      this.underline,
      this.strikeout,
      this.squiggly,
      this.ink,
    }
)

highlight

final PdfEditorMarkupStyle? highlight

underline

final PdfEditorMarkupStyle? underline

strikeout

final PdfEditorMarkupStyle? strikeout

squiggly

final PdfEditorMarkupStyle? squiggly

ink

final PdfEditorInkStyle? ink

PdfEditorConfiguration

class PdfEditorConfiguration

How the editor looks and what it offers. Every field is optional; leave one out and the editor keeps its own behaviour. Every option only narrows or restyles — values outside what the editor supports are clamped by the native SDK.

The same options as the native PDFEditorConfiguration / PdfEditorConfiguration, minus the ones that can't cross a platform channel: custom icons and your own buttons (images and callbacks) stay native-only.

PdfEditorConfiguration

const PdfEditorConfiguration(
    {
      this.modes,
      this.hiddenTools,
      this.hiddenMenuItems,
      this.colorScheme,
      this.minZoom,
      this.maxZoom,
      this.haptics,
      this.showsUsageHints,
      this.localization,
      this.toolTitles,
      this.modeTitles,
      this.menuItemTitles,
      this.toolOrder,
      this.menuOrder,
      this.interfaceFontFamily,
      this.fonts,
      this.fontsTitle,
      this.showsStandardFonts,
      this.showsDocumentFonts,
      this.showsDeviceFonts,
      this.allowsFontImport,
      this.newTextFont,
      this.selectionColor,
      this.selectionColorDark,
      this.handleFillColor,
      this.handleShape,
      this.handleScale,
      this.selectionBorderWidth,
      this.searchHighlightColor,
      this.searchCurrentHighlightColor,
      this.toolDefaults,
      this.colors,
      this.colorsDark,
      this.actionTitles,
      this.hiddenActions,
      this.actionOrder,
      this.markupColors,
      this.inkColors,
      this.signatureColors,
      this.stamps,
      this.allowsCustomStamp,
      this.fontSizes,
      this.signatureMethods,
      this.signaturePlacement,
      this.showsUndoRedo,
      this.showsPageNavigator,
      this.showsZoomControls,
    }
)

modes

final List<PdfEditorMode>? modes

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

hiddenTools

final Set<PdfEditorTool>? hiddenTools

Tools removed from every mode that carries them.

hiddenMenuItems

final Set<PdfEditorMenuItem>? hiddenMenuItems

Items removed from the ⋮ menu.

colorScheme

final PdfEditorColorScheme? colorScheme

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

minZoom

final double? minZoom

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

maxZoom

final double? maxZoom

haptics

final bool? haptics

Taps, snaps and alignment guides.

showsUsageHints

final bool? showsUsageHints

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

localization

final PdfEditorLocalization? localization

The editor's language — see PdfEditorLocalization.

toolTitles

final Map<PdfEditorTool, String>? toolTitles

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

modeTitles

final Map<PdfEditorMode, String>? modeTitles

menuItemTitles

final Map<PdfEditorMenuItem, String>? menuItemTitles

toolOrder

final Map<PdfEditorMode, List<PdfEditorTool>>? toolOrder

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

menuOrder

final List<PdfEditorMenuItem>? menuOrder

Listed ⋮ items first, then the rest.

interfaceFontFamily

final String? interfaceFontFamily

iOS only: the editor's own text in this font family (one the app bundles or the system has).

fonts

final List<String>? fonts

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

fontsTitle

final String? fontsTitle

showsStandardFonts

final bool? showsStandardFonts

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

final bool? showsDocumentFonts

showsDeviceFonts

final bool? showsDeviceFonts

allowsFontImport

final bool? allowsFontImport

newTextFont

final String? newTextFont

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

selectionColor

final Color? selectionColor

The selection box, handles, rotate knob, caret, text-selection band and page guide. Always opaque. selectionColorDark (Android) is used in the dark scheme; on iOS selectionColor is used in both.

selectionColorDark

final Color? selectionColorDark

handleFillColor

final Color? handleFillColor

handleShape

final PdfEditorHandleShape? handleShape

handleScale

final double? handleScale

Handle and knob size, clamped to 0.75–1.5.

selectionBorderWidth

final double? selectionBorderWidth

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

searchHighlightColor

final Color? searchHighlightColor

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

searchCurrentHighlightColor

final Color? searchCurrentHighlightColor

toolDefaults

final PdfEditorToolDefaults? toolDefaults

colors

final PdfEditorColors? colors

The editor's own colours: accent, canvas, toolbars, panels and their ink. colorsDark overrides colors field by field in the dark scheme.

colorsDark

final PdfEditorColors? colorsDark

actionTitles

final Map<PdfEditorAction, String>? actionTitles

Your names for the sub-tools — the property bar's Edit, Color, Font, Crop, Cut, Delete…, the menu over the selection, and the page panel's actions. A name applies wherever the action appears.

hiddenActions

final Set<PdfEditorAction>? hiddenActions

Sub-tools removed wherever they appear.

actionOrder

final List<PdfEditorAction>? actionOrder

Listed sub-tools first, in this order, in every bar and menu that has them; the rest keep the editor's order.

markupColors

final List<Color>? markupColors

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

inkColors

final List<Color>? inkColors

signatureColors

final List<Color>? signatureColors

stamps

final List<PdfEditorStamp>? stamps

The Stamp tool's presets, and whether its Custom Photo button shows.

allowsCustomStamp

final bool? allowsCustomStamp

fontSizes

final List<int>? fontSizes

The font-size list, in points.

signatureMethods

final List<PdfEditorSignatureMethod>? signatureMethods

The signature pad's tabs, in order.

signaturePlacement

final PdfEditorSignaturePlacement? signaturePlacement

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

showsUndoRedo

final bool? showsUndoRedo

The floating pills along the bottom.

showsPageNavigator

final bool? showsPageNavigator

showsZoomControls

final bool? showsZoomControls

toMap

Map<String, Object?> toMap()

The plain-value form both native SDKs read (PDFEditorConfiguration(options:) / PdfEditorConfiguration.fromOptions). Public so a test can check exactly what crosses the channel.

Document API

PdfRect

class PdfRect

A rectangle in page points, top-left origin.

PdfRect

const PdfRect(this.x, this.y, this.width, this.height)

x

final double x, y, width, height

PdfLayerKind

enum PdfLayerKind

text

PdfLayerKind.text

image

PdfLayerKind.image

note

PdfLayerKind.note

signature

PdfLayerKind.signature

drawing

PdfLayerKind.drawing

sound

PdfLayerKind.sound

shape

PdfLayerKind.shape

vector

PdfLayerKind.vector

PdfShape

enum PdfShape

rectangle

PdfShape.rectangle

ellipse

PdfShape.ellipse

line

PdfShape.line

arrow

PdfShape.arrow

PdfLayer

class PdfLayer

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

page

final int page

id

final int id

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

kind

final PdfLayerKind kind

frame

final PdfRect frame

rotation

final double rotation

Degrees, clockwise as seen.

opacity

final double opacity

zIndex

final int zIndex
final String? link

text

final String? text

fontName

final String? fontName

fontSize

final double? fontSize

bold

final bool bold, italic, underline, strikethrough, fontEmbedded

symbolic

final bool symbolic

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

textColor

final Color? textColor, highlightColor

pixelWidth

final int? pixelWidth, pixelHeight

note

final String? note

noteColor

final Color? noteColor, noteTextColor

shape

final PdfShape? shape

fillColor

final Color? fillColor, strokeColor

strokeWidth

final double? strokeWidth

PdfSearchMatch

class PdfSearchMatch

PdfSearchMatch

const PdfSearchMatch(this.page, this.rects)

page

final int page

rects

final List<PdfRect> rects

PdfFormField

class PdfFormField

A form field of the document.

name

final String name

kind

final String kind

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

page

final int page

frame

final PdfRect frame

value

final String value

checked

final bool? checked

exportValue

final String? exportValue

options

final List<String> options

readOnly

final bool readOnly

PdfMetadataKey

enum PdfMetadataKey

title

PdfMetadataKey.title

author

PdfMetadataKey.author

subject

PdfMetadataKey.subject

keywords

PdfMetadataKey.keywords

creator

PdfMetadataKey.creator

producer

PdfMetadataKey.producer

PdfFontFamily

enum PdfFontFamily

The built-in families every PDF reader has.

sans

PdfFontFamily.sans

serif

PdfFontFamily.serif

mono

PdfFontFamily.mono

PdfZOrder

enum PdfZOrder

toBack

PdfZOrder.toBack

backward

PdfZOrder.backward

forward

PdfZOrder.forward

toFront

PdfZOrder.toFront

PdfMarkupKind

enum PdfMarkupKind

highlight

PdfMarkupKind.highlight

strikeout

PdfMarkupKind.strikeout

squiggly

PdfMarkupKind.squiggly

PdfImageKind

enum PdfImageKind

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

photo

PdfImageKind.photo

note

PdfImageKind.note

signature

PdfImageKind.signature

drawing

PdfImageKind.drawing

PdfFormFieldKind

enum PdfFormFieldKind

text

PdfFormFieldKind.text

checkbox

PdfFormFieldKind.checkbox

radio

PdfFormFieldKind.radio

listBox

PdfFormFieldKind.listBox

dropdown

PdfFormFieldKind.dropdown

PdfTextResult

enum PdfTextResult

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

replaced

PdfTextResult.replaced

overflow

PdfTextResult.overflow

PdfDocumentException

class PdfDocumentException implements Exception

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.

PdfDocumentException

const PdfDocumentException(this.code, this.message)

code

final String code

message

final String message

PdfDocument

class PdfDocument

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

final doc = await PdfDocument.open(bytes);
for (final block in await doc.textBlocks(0)) {
  await doc.setText(block, await translate(block.text!), shrinkToFit: true);
}
final edited = await doc.save();
await doc.close();

open

static Future<PdfDocument> open(
    Uint8List bytes,
    {
      String? password,
    }
) async

Open bytes headless, with the system's fonts for every script.

close

Future<void> close() async

Free the native document. Calls after this fail with notFound.

pageCount

Future<int> get pageCount async

pageSize

Future<Size> pageSize(int page) async

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

save

Future<Uint8List> save() async

The edited PDF.

metadata

Future<String> metadata(PdfMetadataKey key) async

setMetadata

Future<void> setMetadata(PdfMetadataKey key, String value)

Written into the file save produces.

text

Future<String> text(int page) async

The page's plain text.

search

Future<List<PdfSearchMatch>> search(
    String query,
    {
      bool caseSensitive = false,
    }
) async

Every match of query in the document.

renderPage

Future<Uint8List?> renderPage(int page, int width, int height)

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

canUndo

Future<bool> get canUndo async

canRedo

Future<bool> get canRedo async

undo

Future<bool> undo() async

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

redo

Future<bool> redo() async

insertBlankPage

Future<void> insertBlankPage(
    int index,
    {
      double width = 0,
      double height = 0,
    }
)

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

deletePage

Future<void> deletePage(int index)

movePage

Future<void> movePage(int from, int to)

duplicatePage

Future<void> duplicatePage(int index)

rotatePage

Future<void> rotatePage(int index, {bool clockwise = true})

importPages

Future<void> importPages(
    Uint8List bytes,
    {
      String? password,
      List<int>? pages,
      int? index,
    }
)

Copy pages (all when null) of another PDF in at index (null = the end). Layer ids must be read again.

extractPages

Future<Uint8List> extractPages(List<int> pages) async

pages of this document as a new PDF.

layers

Future<List<PdfLayer>> layers(int page)

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

textBlocks

Future<List<PdfLayer>> textBlocks(int page)

layer

Future<PdfLayer> layer(PdfLayer layer)

The layer as it is now.

image

Future<Uint8List?> image(PdfLayer layer)

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

sound

Future<Uint8List?> sound(PdfLayer layer)

The audio of a sound layer.

setText

Future<PdfTextResult> setText(
    PdfLayer layer,
    String text,
    {
      bool shrinkToFit = false,
    }
) async

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

Future<void> setFontSize(PdfLayer layer, double points)

setFont

Future<void> setFont(
    PdfLayer layer,
    PdfFontFamily family,
    {
      bool bold = false,
      bool italic = false,
    }
)

setFontData

Future<void> setFontData(PdfLayer layer, Uint8List data, String name)

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

setTextStyle

Future<void> setTextStyle(PdfLayer layer, {bool? bold, bool? italic})

Bold / italic of the current family; null leaves that one as it is.

setUnderline

Future<void> setUnderline(PdfLayer layer, bool on)

setStrikethrough

Future<void> setStrikethrough(PdfLayer layer, bool on)

setFillColor

Future<void> setFillColor(PdfLayer layer, Color color)

Text colour, or a shape's fill.

setStrokeColor

Future<void> setStrokeColor(PdfLayer layer, Color color)

setStrokeWidth

Future<void> setStrokeWidth(PdfLayer layer, double points)

setOpacity

Future<void> setOpacity(PdfLayer layer, double opacity)

setFrame

Future<void> setFrame(PdfLayer layer, PdfRect frame)

Move and resize (text scales uniformly).

setRotation

Future<void> setRotation(PdfLayer layer, double degrees)

Degrees, clockwise as seen.

setZOrder

Future<void> setZOrder(PdfLayer layer, PdfZOrder order)
Future<void> setLink(PdfLayer layer, String? url)

null removes the link.

setSound

Future<void> setSound(PdfLayer layer, Uint8List audio, String name)

replaceImage

Future<void> replaceImage(PdfLayer layer, Uint8List image)

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

setMarkup

Future<void> setMarkup(PdfLayer layer, PdfMarkupKind kind, Color color)

Mark a whole text layer up.

removeMarkup

Future<void> removeMarkup(PdfLayer layer)

delete

Future<void> delete(PdfLayer layer)

duplicate

Future<PdfLayer> duplicate(
    PdfLayer layer,
    {
      double dx = 12,
      double dy = 12,
    }
)

A copy offset by (dx, dy) points.

copy

Future<PdfLayer> copy(PdfLayer layer, int toPage, double x, double y)

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

addText

Future<PdfLayer> addText(
    String text,
    int page,
    double x,
    double y,
    {
      double fontSize = 14,
      Color color = const Color(0xFF000000),
      PdfFontFamily family = PdfFontFamily.sans,
    }
)

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

addImage

Future<PdfLayer> addImage(
    Uint8List image,
    int page,
    PdfRect frame,
    {
      PdfImageKind kind = PdfImageKind.photo,
      String? note,
    }
)

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

addShape

Future<PdfLayer> addShape(
    PdfShape shape,
    int page,
    Offset from,
    Offset to,
    {
      Color fill = const Color(0x00000000),
      Color stroke = const Color(0xFF000000),
      double strokeWidth = 2,
    }
)

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

markupText

Future<void> markupText(
    int page,
    Offset from,
    Offset to,
    {
      PdfMarkupKind kind = PdfMarkupKind.highlight,
      Color color = const Color(0xFFFFE44D),
    }
)

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

formFields

Future<List<PdfFormField>> formFields() async

setFormValue

Future<void> setFormValue(String field, String value)

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

fillForm

Future<void> fillForm(Map<String, String> values)

Fill several fields at once.

addFormField

Future<String> addFormField(
    PdfFormFieldKind kind,
    int page,
    PdfRect frame,
    {
      String? name,
      List<String> options = const <String>[],
    }
) async

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

deleteFormField

Future<void> deleteFormField(String name)

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

resetForm

Future<void> resetForm()

flattenForm

Future<void> flattenForm()

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

SDK, licensing and callbacks

PdfEditorLicense

class PdfEditorLicense

The license verdict, as the native SDK decided it.

status

final String status

valid, unlicensed, invalid, expired, wrongApp, wrongPlatform, versionNotCovered, … and for an online key suspended (the vendor suspended it) or verificationRequired (not confirmed with the license server yet — the native SDK confirms it on its own).

isLicensed

final bool isLicensed

reason

final String reason

A sentence saying why — show it to yourself, in a debug build, when isLicensed is false.

licensee

final String licensee

plan

final String plan

expires

final String? expires

identity

final String identity

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

licenseId

final String licenseId

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

updatesUntil

final String? updatesUntil

"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

final bool isOnline

An online key: confirmed with the vendor's license server, which can suspend and resume it.

paymentDue

final bool paymentDue

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

message

final String message

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