Repository navigation
Write a markup annotation's comment as rich text - #110
Merged
Merged
Conversation
/RC is an entry of every markup annotation (ISO 32000-2 §12.5.6.2): the text its popup shows. Only a free text draws it. EPDFAnnot_SetRichTextJSON and EPDFAnnot_SetRichTextXHTML now write any other markup annotation's /RC and its plain projection in /Contents, nothing else: no /DS, /DA or appearance, as Acrobat writes a note's. The body states only what differs from a comment that states nothing (the reader's face, 12 pt, black, left-aligned), so a comment written with the body it was read with reads back the same. Links, popups and widgets are refused. Tests read Acrobat 26's note (text_rich_comment_acrobat.pdf: no body style, Enter as inside a span, an impossible font-size:-14.0pt on every span), write a comment, write Acrobat's back, and refuse a link and a popup.
This was referenced Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
/RCis an entry of every markup annotation (ISO 32000-2 §12.5.6.2, Table 171): the formatted text its popup shows. Only a free text draws it. Until now our rich text setters only wrote a free text, so a note's comment couldn't be written formatted, and an edited note kept Acrobat's old/RCnext to its new/Contents.EPDFAnnot_SetRichTextJSONandEPDFAnnot_SetRichTextXHTMLnow write any other markup annotation's comment (text, line, square, circle, polygon, polyline, the four text markups, caret, stamp, ink, file attachment, sound, redact, projection):/RCand its plain projection in/Contents, nothing else. No/DS,/DAor appearance, as Acrobat writes a note's.The writer (
CPDF_RichTextWriter::ApplyComment,SerializeCommentRC) shares the envelope with the free text one;SerializeRCis unchanged.Checked against Acrobat
text_rich_comment_acrobat.pdfis a note written by Acrobat 26: no body style, Enter as inside a span, andfont-size:-14.0pton every span, a size nothing can be. We read it as rich text, the body's size kept, and writing it back reads the same, without the impossible size.Tests
AcrobatNoteCommentReadsAsRichText: Acrobat's note reads asrcwith its bold, underline and italic runs and its line breaks.SetRichTextJSONWritesACommentAsAcrobatDoes: a note's exact/RC(no body style) and/Contents, no/DS,/DAor/AP; a square whose body differs states only its size and colour.AcrobatCommentWrittenBackReadsTheSame: Acrobat's comment, read and written back, reads the same.SetRichTextJSONRefusesKindsThatArentMarkup: a link and a popup are refused.Three deliberate breaks in the new code each failed a test. On macOS the 203 annotation and rich text embedder tests pass. The engine's annotation conformance passes on the local engine (1923) and the cloud engine (1120) against a runtime built from this branch. The full suites and Linux CI haven't run yet.
Found on the way, not changed here: inside a layer document, writing to this fixture's note promotes no object into the layer. Upstream's
FPDFAnnot_SetStringValuedoes the same, so it isn't new. The file keeps its objects in object streams, which may be why.The engine side (
richTexton every markup kind, and acontentsedit rewriting a formatted comment instead of leaving stale/RC) is on embedpdf/embed-pdf-viewerfeature/markup-rich-text, which needs this released and pinned.