Skip to Content
NexPDF

Annotations and measurements

Let users annotate, comment on and measure PDFs in an Electron window with NexPDF, and choose the tools, colours and stamps they get.

English

License module

Creating and changing annotations and measurements needs the annotations module (Indie tier and above). Showing annotations works without a key.

The Annotate mode

The Annotate mode (annotations) has these tools, each with its id in the configuration:

ToolsIds
Notenote
Pen, highlighter pen, eraserink, inkHighlight, eraser
Highlight, underline, strikethrough, squigglyhighlight, underline, strikeout, squiggly
Rectangle, ellipse, arc, polygon, cloud, polyline, line, arrowsquare, circle, arc, polygon, cloud, polyline, line, arrow
Text box, callout, stamp, signature, image stamp, linkfreetext, callout, stamp, signature, image, link

The comments tab of the side panel lists the document's comments.

Choose the tools, colours and stamps

const fs = require('node:fs');
const path = require('node:path');

const config = path.join(app.getPath('userData'), 'nexpdf-ui.json');
fs.writeFileSync(config, JSON.stringify({
  modeConfig: { initialMode: 'annotations', availableModes: ['viewer', 'annotations'] },
  annotationsConfig: {
    availableTools: ['note', 'ink', 'highlight', 'underline', 'square', 'arrow', 'freetext', 'stamp'],
    defaultColor: '#2557D6',
    colorPalette: ['#2557D6', '#E5372B', '#2FB344', '#1D1B18'],
    presets: { ink: { color: '#1D4ED8', width: 3 }, highlight: { color: '#FDE047', opacity: 0.35 } },
    stamps: ['APPROVED', 'REJECTED', 'DRAFT'],
  },
  collaboration: { userName: 'Ana Silva' },
}));
await openPdfWindow({ file, config });
KeyWhat it does
annotationsConfig.availableToolsThe tools to offer, in this order
annotationsConfig.defaultColor / defaultOpacityThe colour (#RRGGBB or #RRGGBBAA) and opacity (0.05 to 1) new annotations start with
annotationsConfig.colorPaletteThe swatches in the style picker
annotationsConfig.presetsThe style each tool starts with: color, opacity, width, fontSize
annotationsConfig.rememberStylesEach tool starts with the last style picked on this machine (default true)
annotationsConfig.stampsThe texts the stamp tool offers, at most 40 characters each
annotationsConfig.defaultFontSizeThe font size of text boxes
collaboration.userNameThe name shown on comments

The Measure mode

The Measure mode (measurement) measures distances, perimeters and areas on the page and saves them in the PDF with Save in PDF. Include measurement in modeConfig.availableModes to offer it.

Keep the annotated file

pdf.save(path) writes the document with every annotation, and pdf.bytes() returns it as a Buffer. To annotate in code, use the document API (openDocumentFile, then the calls of the Node.js SDK).

On this page