Resize canvas
resize_canvasResize the document canvas to new width and height, with optional viewBox adjustment or print bleed.
Instructions
Set the document canvas width / height to validated CSS lengths.
When to use: changing the PAGE size. To crop the page to the art use fit_to_content, to repair
the viewBox use normalize_viewbox, to resize one OBJECT use scale_object.
Key params: width/height are validated CSS lengths; child geometry is not altered. By
default an existing viewBox is preserved (synthesized only when absent). adjust_viewbox=True
RETARGETS the viewBox to "0 0 W H" so it tracks the new canvas (opt-in; changes the
coordinate system). BLEED (opt-in): bleed > 0 ALSO grows the viewBox outward by that
many user units on every side and paints the new border strip with bleed_color (validated
colour, default white) via one background <rect> behind all content — a print-bleed resize in
ONE call instead of a second scale_object/background step. bleed needs a valid existing or
derivable viewBox and is mutually exclusive with adjust_viewbox.
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: resize_canvas(doc_id, "800", "600"); with bleed:
resize_canvas(doc_id, "800", "600", bleed=8, bleed_color="#fff")
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 |
|---|---|---|---|
| bleed | No | ||
| width | Yes | ||
| doc_id | Yes | ||
| height | Yes | ||
| bleed_color | No | #ffffff | |
| adjust_viewbox | No |
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 |