This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/web/release-notes/1-27.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. 1.27 release notes

1.27 release notes

RSS

Nutrient Web SDK 1.27 adds the instance.load() method, which loads another document into a viewer that’s already mounted. The instance, its event listeners, and its user interface (UI) customization stay in place.

This release also includes these changes:

  • The createdAt property is null when a document stores no creation date, and updatedAt falls back to the creation date.
  • Two new options protect unsaved changes when the viewer unloads or the user leaves the page.
  • Each NutrientViewer.load() call applies its own dynamicFonts and fontSubstitutions values.
  • AI Assistant waits 90 seconds for response data instead of 30.
  • The instance.getDefaultEmbeddedFile() method returns the file that a PDF Portfolio opens by default.

For a complete list of changes and fixes, refer to the changelog.

Switching documents in a mounted viewer

Before 1.27, showing another document required NutrientViewer.unload() followed by NutrientViewer.load(). This created a new instance, so an application had to register its event listeners and apply its UI customization again.

In standalone mode, the instance.load() method loads another document into the same viewer:

const instance = await NutrientViewer.load({
container: "#viewer",
document: "/first.pdf",
});
// Load another document into the same viewer.
await instance.load({ document: "/second.pdf" });

The promise resolves to the same instance. The viewer retains its event listeners, toolbar items, annotation presets, theme, locale, custom UIs, and custom renderers. It also reuses the WebAssembly engine.

The page, zoom, rotation, and scroll position reset for the new document. The SDK also resets the interaction mode and clears the selection, the search, and the undo history.

The method accepts the following keys and rejects any other key with an error:

  • document — The document to load, as a URL or an ArrayBuffer.
  • password — The password of a protected document. Without it, the SDK calls the onPasswordRequired callback once. The method never shows the password prompt.
  • initialViewState — The page, zoom, rotation, layout, or scroll mode that the new document opens with. Derive the value from the current view state — for example, with instance.viewState.set("currentPageIndex", 2). The method rejects a view state that changes a viewer setting, such as readOnly or sidebarMode. A new ViewState instance carries the defaults for those settings, so the method usually rejects it.

The rejected keys include instantJSON and XFDF, because the method doesn’t import annotations during a load.

The following also applies:

  • With AutoSaveMode.IMMEDIATE or AutoSaveMode.INTELLIGENT, the SDK saves pending changes before the switch. With AutoSaveMode.DISABLED, it discards them, so call instance.save() first.
  • A save doesn’t carry changes over to the new document. To retain the changes, export them after the save — for example, with instance.exportPDF() or instance.exportInstantJSON().
  • The SDK discards unsaved Content Editor changes in every autosave mode. Save them in the Content Editor before the call.
  • Calls run one at a time. When several calls wait, only the most recent call runs. A superseded call rejects with an error that NutrientViewer.isDocumentLoadSupersededError() recognizes.
  • When a load fails, the previous document usually stays open. The NutrientViewer.isPreviousDocumentClosedError() function recognizes errors from loads that closed the previous document.
  • The document.willSwap event fires when the new document has opened, and the document.swap event fires when it’s ready.

A superseded call is part of normal use — for example, when a user switches documents quickly. Every instance.load() call therefore needs a rejection handler, or the browser reports unhandled promise rejections:

async function switchDocument(nextDocument) {
try {
await instance.load({ document: nextDocument });
} catch (error) {
// A newer call replaced this one before it started.
if (NutrientViewer.isDocumentLoadSupersededError(error)) return;
throw error;
}
}

The method isn’t available in server-backed mode or with DWS Viewer API. In those cases, unload the viewer and load it again.

For more information, refer to the switch documents guide and the instance.load() API reference.

Missing annotation and comment dates

A PDF doesn’t have to store a creation or modification date for an annotation or comment. When a date was missing, the createdAt and updatedAt properties used to return the time the document was opened.

The createdAt property is now null when the document stores no creation date. The updatedAt property returns the creation date when the document stores no modification date. It’s null when the document stores neither date. Both properties have the type Date | null.

Code that reads these properties must handle null:

// Before 1.27. This line now throws when the date is missing.
// const created = annotation.createdAt.toISOString();
// 1.27 and later.
const created = annotation.createdAt?.toISOString() ?? null;

TypeScript reports a missing check only when strict null checks are enabled.

The following also changes:

  • The annotations sidebar, comment threads, and the Form Creator show no date when an annotation or comment has none.
  • The toSerializableObject() function omits a missing date. On a serialized comment, createdAt and updatedAt are optional, as they’re already on a serialized annotation.
  • The SDK doesn’t call the dateTimeString callback for a missing date.
  • The instance.update() method retains an existing creation date when it receives createdAt: null.

In standalone mode, the following also applies:

  • The instance.exportInstantJSON() method omits createdAt for an annotation without a creation date. Before 1.27, it set createdAt to the time of the export.
  • Annotations imported from Instant JSON or XML Forms Data Format (XFDF) have only the dates that the data contains.
  • The instance.create() method still sets the current time on an annotation without dates.

With Document Engine, annotations that a PDF stores without dates retain the date that Document Engine assigned to them.

For more information, refer to the createdAt and updatedAt API references.

Protecting unsaved changes

Two new configuration options protect unsaved changes. Both are disabled by default:

  • onBeforeUnload — A synchronous callback that the SDK calls before NutrientViewer.unload() removes the viewer. Returning false stops the unload, and NutrientViewer.unload() returns false.
  • warnOnUnsavedChanges — When this option is true, the browser shows its own warning before the user leaves the page. The warning appears only while instance.hasUnsavedChanges() returns true.

The following example enables both options:

NutrientViewer.load({
// Don't unload the viewer while it has unsaved changes.
onBeforeUnload: (instance) => !instance.hasUnsavedChanges(),
warnOnUnsavedChanges: true,
});

The following limits apply:

  • The callback doesn’t support promises. If it returns a promise, NutrientViewer.unload() throws an error.
  • The callback doesn’t run when a framework or other code removes the viewer’s container from the page.
  • Browsers control the text of the warning and usually show it only after the user interacts with the page. The warning may not appear on mobile browsers.
  • The browser can’t wait for a save to finish.
  • In standalone mode, having no unsaved changes doesn’t mean that the PDF was exported or uploaded.

For more information, refer to the detect unsaved changes guide.

Font options for each load

In earlier versions, a load could ignore its dynamicFonts and fontSubstitutions options when NutrientViewer.preloadWorker() or an earlier NutrientViewer.load() on the page ran with different values. Text in non-embedded fonts then stayed blank.

Each NutrientViewer.load() call now applies its own dynamicFonts and fontSubstitutions values. A call without these options no longer applies the values from NutrientViewer.preloadWorker() or an earlier load. Fonts that an earlier call downloaded stay available until the page reloads.

If your application relied on the earlier values, pass the options to each call:

const configuration = {
container: "#viewer",
document: "/document.pdf",
dynamicFonts: "https://example.com/assets/fonts.json",
};
// Pass the font options to the preload and to each load.
await NutrientViewer.preloadWorker(configuration);
await NutrientViewer.load(configuration);

For more information, refer to the font substitution guide.

AI Assistant response timeout

AI Assistant used to stop with an error when it received no response data for 30 seconds. On large documents, this happened while the service was still working on the response.

The default timeout is now 90 seconds. To change it, set streamInactivityTimeout in the aiAssistant configuration to a value in milliseconds:

NutrientViewer.load({
aiAssistant: {
sessionId: "session123",
jwt: "your-jwt-token",
backendUrl: "http://localhost:4000",
// Wait up to three minutes for response data.
streamInactivityTimeout: 180000,
},
});

The value must be greater than 30000 and at most 2147483647. Increase it when a proxy between the browser and the AI Assistant service delays or buffers the response.

For more information, refer to the AI Assistant integration guide.

Default file of a PDF Portfolio

A PDF Portfolio stores its documents as embedded files and can name one of them as the file to open first. PDF viewers such as Adobe Acrobat show that file instead of the portfolio’s cover page.

The instance.getDefaultEmbeddedFile() method returns this file, or null when the document doesn’t name a default file:

const defaultFile = await instance.getDefaultEmbeddedFile();
if (defaultFile) {
const fileContent = await instance.getAttachment(defaultFile.attachmentId);
}

In server-backed mode, the method requires Document Engine 1.21.0 or later, which isn’t released yet. With an older version, it always resolves to null.

This release supports Document Engine 1.5.6 or later. Specific features in server-backed mode require newer versions:

  • Document Engine 1.15.0 or later — Form fields without the fillable highlight when the viewer is read-only.
  • Document Engine 1.16.0 or later — SearchType.WORD_BASED, PDF exports without password protection, and removing annotation notes after an XFDF roundtrip.
  • Document Engine 1.18.0 or later — Document-defined annotation tab order, Annotation.createdBy, overprintPreview, and blackRendering.
  • Document Engine 1.20.0 or later — Viewing and toggling PDF layers. This version also fixes text selection highlights that skip spaces between words in certain PDFs after optical character recognition (OCR).
  • Document Engine 1.21.0 or later — instance.getDefaultEmbeddedFile() and document order for annotations from an uploaded PDF when forceRenderWidgetsInAnnotationsOrder is true. This version isn’t released yet.

In server-backed mode, Document Engine runs the PDF engine, so the engine fixes in this release also require Document Engine 1.21.0. One of them fixes text selection gaps in scanned PDFs whose OCR text layer draws each space as a separate text object. The others cover Symbol font characters, redaction, and saved PDFs. The faster first-page load requires this version too.

Document Engine ignores compound measurements, which work only in standalone mode.

For version requirements, refer to the Web SDK and Document Engine compatibility requirements guide.

For the previous release, refer to the Web SDK 1.26 release notes.