Fit canvas to content
fit_to_contentAdjust the document's viewBox to tightly fit the content bounding box, cropping the page to frame the drawing exactly.
Instructions
Fit the document's root viewBox to its CONTENT bounding box.
When to use: cropping the page so it frames the drawing exactly. To set an explicit page size
use resize_canvas, to merely repair the viewBox use normalize_viewbox.
Key params: none beyond doc_id. The content bbox is computed by the Inkscape engine
(--query-all, ADR-005 — real geometry, not naive XML) in the document's intrinsic
user-coordinate space (probed against a px-identity copy so the value is STABLE across calls);
only the root viewBox changes. IDEMPOTENT: a second call on an already-fitted document reports
changed=False. Fails with a stable error if the engine is unavailable, the document has no
drawable content, or the bbox is degenerate.
Return shape: EditResult — operation_id, snapshot_id, changed (real before/after content
diff), before/after preview; the edit lands on the working copy only (reversible).
Example: fit_to_content(doc_id)
Render and look before you trust this edit: render with render_preview (or live_render_view)
and inspect the result before relying on it; restore_snapshot reverts it if it is wrong.
Risk class: medium.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| doc_id | Yes | ||
| changed | Yes | ||
| summary | No | ||
| snapshot_id | Yes | ||
| operation_id | Yes | ||
| preview_after | No | ||
| preview_before | No |