Catalog/design-fit-on-page

Design

Scale to fit page API

Scales a content box to fit inside a page minus margins while preserving aspect ratio, returning the scale factor, fitted size, and centering offsets. Answers 'What scale fits a 300x400mm artwork onto A4 with 10mm margins?', 'Where do I position it to center it on the page?'.

Price$0.04per request
MethodPOST
Route/v1/design/fit-on-page
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
designprintfit-on-pagescale-to-fitcontainlayoutpageshrink
API URLhttps://x402.hexl.dev/v1/design/fit-on-page
Integration docs
Example request
{
  "contentWidth": 300,
  "contentHeight": 400,
  "pageWidth": 210,
  "pageHeight": 297,
  "marginMm": 10
}
Example response
{
  "contentWidth": 300,
  "contentHeight": 400,
  "pageWidth": 210,
  "pageHeight": 297,
  "marginMm": 10,
  "availableWidth": 190,
  "availableHeight": 277,
  "scale": 0.63333,
  "scalePercent": 63.33,
  "fittedWidth": 190,
  "fittedHeight": 253.333,
  "offsetX": 10,
  "offsetY": 21.833,
  "upscaled": false,
  "interpretation": "Scale content to 63.3% to fit the printable area, centered."
}
Input schema
{
  "type": "object",
  "required": [
    "contentWidth",
    "contentHeight",
    "pageWidth",
    "pageHeight"
  ],
  "properties": {
    "contentWidth": {
      "type": "number",
      "description": "Content width (same units as page)",
      "examples": [
        300
      ]
    },
    "contentHeight": {
      "type": "number",
      "description": "Content height",
      "examples": [
        400
      ]
    },
    "pageWidth": {
      "type": "number",
      "description": "Page width",
      "examples": [
        210
      ]
    },
    "pageHeight": {
      "type": "number",
      "description": "Page height",
      "examples": [
        297
      ]
    },
    "marginMm": {
      "type": "number",
      "description": "Margin on each side (default 0)",
      "examples": [
        10
      ]
    },
    "allowUpscale": {
      "type": "boolean",
      "description": "Permit scaling above 100% (default false)",
      "examples": [
        false
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}