mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-10-24 10:08:00 -06:00
The app, crates, binaries, bundle id, packaging, icons, screenshots and docs are now PdfCraft / pdfcraft (repo storytold/pdfcraft). On first launch the desktop app moves the PrintCraft settings and crash-recovery folders to the new name, and both apps read settings saved under the old storage key, so upgrades keep recent files, preferences and unsaved work. The signing test fixtures keep their PrintCraft subject names (they are binary). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
45 lines
2.2 KiB
Markdown
45 lines
2.2 KiB
Markdown
# pdfcraft-annot
|
|
|
|
Comments (annotations), ISO 32000-2 §12.5. Layer L3, depends only on `pdfcraft-cos`.
|
|
|
|
## What it does
|
|
|
|
- **Builders** for the comment types Acrobat's commenting tools create: sticky note (`Text` +
|
|
`Popup`), highlight, underline, strikethrough, squiggly, rectangle (`Square`), oval (`Circle`),
|
|
line and arrow (`Line` with `/LE`), freehand drawing (`Ink`) and text box (`FreeText`).
|
|
- **Appearance streams** (`appearance::build`) generated from the annotation dictionary, so new
|
|
and restyled comments look the same in every viewer. Highlights multiply (`/BM /Multiply`).
|
|
Note icons are PdfCraft's own drawings. Text boxes use standard Helvetica (WinAnsi), with
|
|
line breaking by approximate Helvetica proportions (no font program is bundled).
|
|
- **Edits:** reply (`/IRT`), set review status (a `/State` reply, as Acrobat's "Set status"
|
|
does), change text, move, resize, restyle, delete (with pop-up and replies).
|
|
|
|
## API sketch
|
|
|
|
```rust
|
|
let index = add_annotation(&mut doc, &NewAnnotation { page, shape, style, contents, author }, &meta)?;
|
|
add_reply(&mut doc, page, index, "Agreed", "Ada", &meta)?;
|
|
set_review_state(&mut doc, page, index, ReviewState::Accepted, "Ada", &meta)?;
|
|
move_annotation(&mut doc, page, index, dx, dy, &meta)?;
|
|
set_style(&mut doc, page, index, Some(rgb), Some(0.5), Some(2.0), &meta)?;
|
|
delete_annotation(&mut doc, page, index)?;
|
|
```
|
|
|
|
A comment is addressed by `(page, index in /Annots)`, the same pair
|
|
`pdfcraft_render::Annotation` reports. `Meta` carries the date and the `/NM` id so edits stay
|
|
deterministic; the engine supplies them.
|
|
|
|
## Fidelity rules
|
|
|
|
- Unknown keys are kept. Inline annotation dictionaries are promoted to indirect objects only
|
|
when an edit needs a reference to them.
|
|
- `set_style` refuses (and changes nothing) when it cannot redraw the comment, e.g. stamps,
|
|
cloudy borders or callouts, instead of leaving a stale appearance.
|
|
- Replies get the parent's `/Rect` and an empty appearance: they appear in comment lists but
|
|
never paint a second icon.
|
|
|
|
## Not yet
|
|
|
|
Callouts, polygons and polylines, clouds, carets (insert/replace text), stamps, file
|
|
attachments, rich text (`/RC`, `/DS`), and the shared named-appearance cache Acrobat writes.
|