Annotation
PDF Annotation
A markup element added to a PDF page, such as highlights, comments, stamps, or drawing shapes.
Technical Detail
In the PDF specification (ISO 32000-2:2020), annotation is implemented as a specialized object within the document's object graph. PDF files use a cross-reference table to index every object by byte offset, enabling random access without sequential parsing. This architecture allows annotation to be read, modified, or extracted independently of other document elements. The binary structure supports incremental saves, where changes append to the file without rewriting existing content.
Example
```javascript
// Add text watermark to PDF pages
const pages = pdf.getPages();
for (const page of pages) {
page.drawText('CONFIDENTIAL', {
x: page.getWidth() / 2 - 100,
y: page.getHeight() / 2,
size: 48,
opacity: 0.2,
rotate: degrees(45),
});
}
```