Skip to Content
NexPDF

Reader

Present the ready-made NexPDF reader screen in a React Native app on iOS and Android, customise it with the shared UI configuration, and listen to its events.

English

NexPdfReader presents the full NexPDF reader screen, the same one as in the iOS and Android SDKs: viewing, annotations, forms, signatures, redaction and the other modes your license includes. You customise it with the shared UI configuration.

Open the reader

import { NexPdfReader } from '@nexdevit/nexpdf-react-native';

const sub = NexPdfReader.addListener('customItemTapped', ({ id }) => console.log('tapped', id));

await NexPdfReader.open({
  document: base64Pdf,
  fileName: 'contract.pdf',
  config: {
    modeConfig: { availableModes: ['viewer', 'annotations'] },
    toolbarConfig: { customItems: [{ id: 'send', title: 'Send', icon: 'send', location: 'top' }] },
    globalConfig: { accentColor: '#0F766E', language: 'pt' },
  },
});
OptionMeaning
documentThe PDF (or DOCX, XLSX, PPTX) as base64. Without it the reader opens empty, with its Open button
fileNameThe name shown in the reader, default document.pdf
configThe UI configuration, see below

open resolves once the reader is shown, full screen. NexPdfReader.close() closes it. Listen for closed to know when the user dismisses it.

Events

addListener(type, listener) subscribes to one event and returns a subscription; call remove() on it to stop.

const subs = [
  NexPdfReader.addListener('documentChanged', ({ filename, pageCount, canUndo }) => setDirty(canUndo)),
  NexPdfReader.addListener('pageChanged', ({ page, pageCount }) => console.log(page, pageCount)),
  NexPdfReader.addListener('closed', () => subs.forEach((s) => s.remove())),
];
EventData
documentLoaded, documentChangedfilename, pageCount, canUndo, canRedo
modeChangedmode
pageChangedpage (1-based), pageCount
customItemTappedid, mode, page
closedfilename: the reader screen was closed

UI configuration

The same JSON configuration customises the NexPDF readers on the web, iOS, Android and Electron. Every key is optional, and unknown keys and ids are ignored.

KeyWhat it does
modeConfig.initialModeThe mode the reader opens in: viewer, annotations, content, pages, forms, signatures, security, redaction, measurement or ai
modeConfig.availableModesThe modes the user can switch to, in this order. With one mode the switcher is hidden
modeConfig.readOnlyViewing only: the viewer mode alone, without undo, redo, open, the page editor or editing rows
toolbarConfig.hiddenItemsBuilt-in items to hide, such as modeSwitcher, undo, redo, search, pages, more, share, close; More menu rows as menu.<id>
toolbarConfig.customItemsYour buttons: { id, title, icon?, location?, modes? }. location is top, toolbar or more (the default). A tap sends customItemTapped
annotationsConfig.availableToolsThe annotation tools to offer, in this order
annotationsConfig.defaultColor / defaultOpacity / colorPaletteThe starting colour and opacity, and the swatches
annotationsConfig.presets / rememberStylesThe style each tool starts with, and whether it remembers the last one
annotationsConfig.stampsThe texts the stamp tool offers
formsConfig.availableToolsThe form field tools to offer
readerConfig.nightModeShows pages with inverted colours
globalConfig.themeMode / accentColorsystem, light or dark, and the brand colour
globalConfig.language / strings / languagesThe interface language, text overrides and extra languages

On iOS and Android the More menu also has menu.pageEditor, menu.handSignature, menu.digitalSign, menu.flatten, menu.imageStamp and menu.license. Item order, the layout and zoom, defaultFontSize, the brand and custom CSS are web-only and ignored here. See the web viewer for the full list of tools and ids.

Getting the edited document back

NexPdfReader has no call that returns the edited document to JavaScript. Users save or share it from the reader itself (the share item). To change documents from code, use PdfDocument instead.

On this page