Skip to Content
NexPDF

Comment threads

Reply to annotations, read whole comment threads and set review states such as Accepted or Completed on the device with NexPDF for React Native.

English

License module

Replies and review states need the annotations module (Indie tier and above).

A comment thread is an annotation (a note, a highlight, any markup) with the replies people wrote under it. Replies are annotations too, so Acrobat and other viewers show the same thread. An annotation is named by its object number and generation (num, gen), as annotations(page) lists them.

Reply

replyToAnnotation(pageIndex, num, gen, author, text) adds a reply and resolves to the reply's object number (its generation is 0). Reply to a reply the same way.

import { NexPdf } from '@nexdevit/nexpdf-react-native';

const doc = await NexPdf.open(reviewBase64);
const [note] = await doc.annotations(0);
const reply = await doc.replyToAnnotation(0, note.num, note.gen, 'Rui', 'Agreed, changing the date.');
await doc.replyToAnnotation(0, reply, 0, 'Ana', 'Thanks!');
const saved = await doc.saveBytes();

Read a thread

annotationRepliesJson(pageIndex, num, gen) resolves to the thread under an annotation, oldest first, replies to replies included:

for (const r of JSON.parse(await doc.annotationRepliesJson(0, note.num, note.gen))) {
  console.log(r.date, r.author, r.text, r.in_reply_to, r.state);
}

Each entry has num, gen, in_reply_to ({"num", "gen"}), author, date (ISO 8601), text, state and state_model. state and state_model are null for plain replies.

Set a review state

setAnnotationState(pageIndex, num, gen, author, state) records a reviewer's decision as a hidden state reply and resolves to its object number:

ModelStates
ReviewAccepted, Rejected, Cancelled, Completed, None
MarkedMarked, Unmarked
await doc.setAnnotationState(0, note.num, note.gen, 'Ana', 'Accepted');

Threads and states are also part of real-time collaboration: replies sync as comment records.

On this page