TPTruPDF

@trupdf/core

The viewer engine. Hosts that don't need the SDK abstraction import directly from this package.

Exports

Viewer

  • DocViewer — React component, top-level entry.
  • ViewerEngine — central state machine (see method groups below).
  • PageRenderer — DPR-aware page render via the TruPDF render engine, with cancellation + per-page LRU.
  • DocumentLoader — URL / ArrayBuffer / password / range load with injectable password callback.
  • SearchManager — search runs in a background Web Worker.

UI

  • Toolbar, SearchBar, ThumbnailPanel, CommentsPanel, ComparePanel, CompareWorkspace, SideBySideCompare, OverlayCompare, FormLayer, PasswordModal, VirtualizedPageList, PageView, TabbedPanel, StylePanel, BookmarksPanel, OutlinePanel, AttachmentsPanel, UICustomizationPanel.
  • UI presets: buildUIPresetConfig, isBuiltInUIPreset, BUILT_IN_UI_PRESETS ('default-ui' | 'alternate-ui' | 'vertical-headers' | 'no-ribbons' | 'ribbons-with-icons').

Touch + a11y

  • bindTouchGestures — pinch-zoom, swipe, rotate, long-press.
  • useKeyboardShortcuts — keyboard shortcut wiring (see Customization → Keyboard).

ViewerEngine

Grab the instance via the engineRef prop on DocViewer.

GroupMethods
DocumentloadDocument(source, opts) (incl. preserveAnnotations?), getState(), destroy()
NavigationgoToPage(n), goToNext(), goToPrev()
ViewsetScale(s), zoomIn(), zoomOut(), fitWidth(), fitPage(), fitAuto(), rotate(deltaDeg)
ModessetSecureMode(on), setReviewMode(on)
ManagersgetPageRenderer(), getSearchManager(), getAnnotationManager(), getFormManager(), getFormScriptEngine(), getToolController(), getSelectionModel(), getAnnotationClipboard(), getPresetStore(), getAuditLogger(), getContentEditStore(), getContentEditEngine(), getLicenseManager(), getSelectionStyle(), getSaveDecorator() / setSaveDecorator()
IdentitygetCurrentUser(), setCurrentUser(user), isEnforcingAuthorEdit(), setEnforceAuthorEdit(on)
UX requestsopenProperties(id), requestReply(id), focusComment(id), openCalibration(), openRichText(id)
Layers (OCG)getLayerGroups(), getLayerOrder(), setLayerVisibility(id, on), applyOCGState(), getOptionalContentConfig(), requestRerender()
RedactionapplyRedactions({ actor?, reload? }), getPendingRedactionCount()
Content editapplyContentEdits({ reload?, signal? }), getPendingContentEditCount()
PDF/AgetPdfAClaim(), validatePdfA(options), getTaggedPdfInfo(), getStructureTree(page)

Engine events

EventPayload
state.changedfull state snapshot
document.loadedthe loaded document
document.errorError
document.destroyedvoid
page.changedpage number
scale.changedscale
rotation.changeddegrees
secureMode.changedbool
loading.progress{ loaded, total, progress }
redaction.applied / redaction.failedburn result / error
content-edits.changed / applied / failedpending count / result / error
properties.requested / reply.requestedannotation id
comment.focusRequestedannotation id
calibration.requested / richtext.requestedrequest context
layers.visibilityChangedlayer state
render.refreshRequestedvoid

Operations

SaveEngine

save / saveAll / saveRasterized / download / downloadAll.

interface SaveOptions {
  originalBytes?: Uint8Array;
  signal?: AbortSignal;
  attachmentName?: string; // default TRUPDF_XFDF_ATTACHMENT_NAME ('trupdf-annotations.xfdf')
  skipXfdfAttachment?: boolean;
  skipAnnotations?: boolean;
  watermark?: WatermarkOptions;
}

ExportEngine

  • exportImage({ page, scale? = 2, mime?, quality? = 0.92, rect? }) — PNG/JPEG/WebP/BMP.
  • exportText({ pages?, pageSeparator? }).
  • exportHtml(options).
  • exportFlattenedPdf(scale = 2).

PrintEngine

print({ pages?, title?, withAnnotations? = true, renderScale? = 1.5, onProgress?, onBeforePrint?, signal? }).

AttachmentEngine

list() / extract(name) / remove(name) / removeAndReload(name) — embedded-file attachments.

Page operations (pure functions)

insertBlankPages, deletePages, rotatePages, reorderPages, extractPages, replacePages, mergePdfs, splitPdf, cropPage, cropPages, plus the PAGE_SIZES constant. imageToPdf(bytes, mime) wraps an image into a single-page PDF.

Document generation

renderTemplate + generateSimplePdf — Mustache-subset templating written directly into a fresh PDF.