Forum News

PDF Comments / Annotations

mikeday
The latest build of Prince now supports PDF text annotations!

You can create a PDF text annotation on an element or pseudo-element with these new properties:

prince-pdf-annotation-type: none | text
prince-pdf-annotation-contents: none | <string>
prince-pdf-annotation-author: none | <string>
prince-pdf-annotation-title: none | <string>
prince-pdf-annotation-createdate: none | <string> (in ISO 8601 format)
prince-pdf-annotation-modifydate: none | <string> (in ISO 8601 format)
prince-pdf-annotation-color: <color>

prince-pdf-annotation-position:
( <x-edge> <length-percent>? ) || ( <y-edge> <length-percent>? )

<x-edge> = left | right | page-left | page-right
<y-edge> = top | bottom | page-top | page-bottom

Here is an example:
span.annot {
    prince-pdf-annotation-type: text;
    prince-pdf-annotation-author: "Author Name";
    prince-pdf-annotation-contents: "Here is the annotation contents"
}

We may support other PDF annotation types in the future, please let us know your experiences with PDF annotations! :D
mikeday
The latest build of Prince now supports more PDF comments!

prince-pdf-annotation-type: none | text | highlight | underline | wavy | line-through

Where 'wavy' maps to the Squiggly annotation type in PDF and 'line-through' maps to the StrikeOut annotation type in PDF.

The color property has a new default 'auto' value that chooses a default color based on the annotation type:

prince-pdf-annotation-color: auto | <color>
  • icons and highlights are yellow
  • underlines and squiggly underlines are green
  • strike-outs are red
howcome
Here's a short guide to writing PDF comments with Prince:

https://css4.pub/2022/comments/