---
title: "Flatten PDF annotations in Node.js | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/nodejs/annotations/flatten-annotations/"
md_url: "https://www.nutrient.io/guides/nodejs/annotations/flatten-annotations.md"
last_updated: "2026-05-14T16:53:43.896Z"
description: "Learn to flatten PDF annotations using Node.js to ensure your document's edits are secure and uneditable. Follow our step-by-step guide!"
---

# Flatten PDF annotations in Node.js

Flattening is the process of embedding annotations in a PDF so that they can no longer be edited or removed. This leaves the visual representation of the annotations intact, but the annotations themselves are removed from the document.

Before you get started, make sure [Nutrient Node.js SDK is up and running](https://www.nutrient.io/sdk/nodejs/getting-started.md).

You can download and use either of the following sample documents for the examples in this guide:

- [Example eight-page PDF](https://www.nutrient.io/assets/nutrient-media/guides/nodejs/files/8-page-example-document.pdf)

- [Example four-page PDF](https://www.nutrient.io/assets/nutrient-media/guides/nodejs/files/4-page-example-document.pdf)





To flatten a PDF document, specify `{ flatten: true }` as a parameter when calling `instance.exportPDF()`.

Example:

```js

import fs from "node:fs";
import { load } from "@nutrient-sdk/node";

const pdfDoc = fs.readFileSync("source.pdf");
const myInstantJSON = JSON.parse(
  fs.readFileSync("instantjson.json", "utf-8")
);

const instance = await load({
  document: pdfDoc,
  instantJSON: myInstantJSON
});
const buffer = await instance.exportPDF({ flatten: true });

fs.writeFileSync("output.pdf", Buffer.from(buffer));
await instance.close();

```
---

## Related pages

- [Export PDF annotations in Node.js](/guides/nodejs/annotations/export-annotations.md)
- [Import PDF annotations in Node.js](/guides/nodejs/annotations/import-annotations.md)
- [PDF annotation library for Node.js](/guides/nodejs/annotations.md)

