---
title: "Embed annotations in PDF using JavaScript | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/web/annotations/save/embed-into-pdf/"
md_url: "https://www.nutrient.io/guides/web/annotations/save/embed-into-pdf.md"
last_updated: "2026-05-26T01:23:09.713Z"
description: "Embedding annotations into a PDF document using Nutrient Web SDK can be done either with the UI or programmatically using the public API."
---

# Embedding annotations in a PDF

Embedding annotations into a PDF document using Nutrient Web SDK can be done either with the UI or programmatically using the [public API](https://www.nutrient.io/api/web/).

In both cases, the API can be used to persist the annotations to the document automatically or on demand.

## Persisting annotations automatically

The annotations are automatically saved to the document without needing to change any setting; the [auto saving mechanism](https://www.nutrient.io/guides/web/annotations/annotation-saving-mechanism.md), which is enabled by default, will take care of persisting any new changes as they take place:

```js

NutrientViewer.load({
  autoSaveMode: NutrientViewer.AutoSaveMode.INTELLIGENT // <- default autoSaveMode
}).then((instance) => {
  instance.addEventListener("annotations.didSave", (annotations) => {
    console.log("Annotations saved!", annotations.toJS());
  });
});

```

## Persisting annotations on demand

If you need more control over when annotations are persisted to the document, disable auto saving and call [`instance.save()`](https://www.nutrient.io/api/web/NutrientViewer.Instance.html#save) at the necessary moment instead:

```js

NutrientViewer.load({
  autoSaveMode: NutrientViewer.AutoSaveMode.DISABLED
}).then((instance) => {
  instance.addEventListener("annotations.create", (annotations) => {
    instance.save();
  });
});

```

Annotations should be saved before exporting or printing the document, so as to ensure all changes are included.

When exporting a document, you have several options. Refer to our guides on [flattening annotations](https://www.nutrient.io/guides/web/annotations/flatten.md) and [incremental saving](https://www.nutrient.io/guides/web/features/document-processing.md) for more details.

Auto saving can be configured for different scenarios and use cases. You can find more information in our [auto save](https://www.nutrient.io/guides/web/features/saving.md) guide.
---

## Related pages

- [Auto saving annotations](/guides/web/annotations/annotation-saving-mechanism.md)
- [Save annotations to external storage](/guides/web/annotations/save/to-external-storage.md)
- [Saving PDF annotations](/guides/web/annotations/save/overview.md)

