Comment threads
Reply to annotations, read whole comment threads and set review states such as Accepted or Completed from a .NET MAUI app.
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. PdfView
has no comment UI; build your own list from these calls. An annotation is named by its object number
and generation (num, gen), as AnnotationsJson lists them.
Reply
ReplyToAnnotation(pageIndex, num, gen, author, text) adds a reply and returns the reply's object
number (its generation is 0):
using System.Text.Json.Nodes;
var doc = view.Document!;
var page = view.CurrentPage;
var note = JsonNode.Parse(doc.AnnotationsJson(page))!.AsArray()[0]!;
var num = note["num"]!.GetValue<uint>();
var gen = note["gen"]!.GetValue<ushort>();
var reply = doc.ReplyToAnnotation(page, num, gen, "Rui", ReplyEntry.Text);
doc.Save(Path.Combine(FileSystem.AppDataDirectory, "review.pdf"));Reply to a reply the same way, with (uint)reply and generation 0.
Read a thread
AnnotationRepliesJson(pageIndex, num, gen) returns the thread, oldest first, replies to replies
included. Each entry has num, gen, in_reply_to, author, date (ISO 8601), text, state
and state_model:
var thread = JsonNode.Parse(doc.AnnotationRepliesJson(page, num, gen))!.AsArray();
RepliesView.ItemsSource = thread.Select(r => $"{r!["author"]}: {r["text"]}").ToList();Set a review state
SetAnnotationState(pageIndex, num, gen, author, state) records a reviewer's decision as a hidden
state reply: Accepted, Rejected, Cancelled, Completed or None (Review model), or Marked
and Unmarked (Marked model).
doc.SetAnnotationState(page, num, gen, "Ana", "Accepted");Replies sync as comment records in real-time collaboration.