Bundled images and scaling
POST /pdf/generate/bundle accepts an HTML or Markdown request and separate
binary image files in one authenticated multipart upload. Templates reference
image names; neither the template nor the request JSON needs base64 data URLs.
The existing JSON /pdf/generate endpoint is unchanged.
Request format
Send one text field named request containing the same JSON object documented
in Generate PDF Job, and one or more file parts named assets. Each file part’s
filename is its logical name, including any relative directories. All names
are relative to the bundle root, including URLs in the inline CSS template.
Template filename metadata does not change this root.
For example, a local directory can contain:
request.json
assets/
logo.svg
portrait.jpg
request.json:
{
"html_template": {
"content": "<img class='logo' src='assets/logo.svg' alt='Company'><img class='portrait' src='assets/portrait.jpg' alt='Portrait'>"
},
"css_template": {
"content": ".logo {width:40mm;height:15mm;object-fit:contain} .portrait {width:35mm;height:45mm;object-fit:cover;object-position:center}"
}
}
Upload with curl after obtaining the usual bearer token:
curl --fail-with-body "$INFLUXION_BASE_URL/pdf/generate/bundle" \
-H "Authorization: Bearer $TOKEN" \
-F 'request=<request.json;type=application/json' \
-F 'assets=@assets/logo.svg;filename=assets/logo.svg;type=image/svg+xml' \
-F 'assets=@assets/portrait.jpg;filename=assets/portrait.jpg;type=image/jpeg'
The response is the usual job_id and document_id. Poll and download using
the existing job endpoints. Swagger also exposes the multipart endpoint.
HTML, Markdown and CSS references
<img class="logo" src="assets/logo.svg" alt="Company logo">
<img class="portrait" src="assets/portrait.jpg" alt="Portrait">
{ width=160 }
.banner { background: url("assets/banner.png") center / cover no-repeat; }
Names are case-sensitive, at most 200 characters, and contain only ASCII letters,
digits, slashes, dots, underscores and hyphens. Absolute paths, backslashes,
./.. path segments, percent escapes, queries and duplicate names are
rejected. Missing named images, including references inside SVG or CSS, put the
job in Error with a useful message. A partial PDF cannot be downloaded.
Use conditional template markup when an image is optional.
The renderer resolves names against an internal virtual origin through the
restricted URL fetcher. It never uses a template URL to open an arbitrary server
file. Absolute remote URLs and existing data URLs retain the deployment’s URL
policy. Set INFLUXION_URL_ALLOWLIST=none (Helm: urlFetch.allowlist: none)
when documents should use only bundled and inline resources. Do not override
the document’s base URL with an HTML <base> element when using bundle names.
Scaling and image quality
Control the printed size in CSS. width with height:auto preserves the
intrinsic aspect ratio. Use mm or cm for predictable physical sizes;
max-width:100% keeps ordinary document images within their container.
img { max-width: 100%; height: auto; }
.logo {
width: 40mm;
height: 15mm;
object-fit: contain; /* whole image, no stretching or cropping */
}
.portrait {
width: 35mm;
height: 45mm;
object-fit: cover; /* fill the box and crop overflow */
object-position: center; /* choose the crop's focal point */
}
For CSS backgrounds, use background-size:contain or cover instead.
SVG logos remain vector graphics in the PDF. Raster images keep their source
resolution; changing their CSS size cannot add detail. For 300 DPI at 40 mm wide,
provide at least 473 pixels of width. Bundling does not resize or recompress files
and does not introduce a second scaling parameter alongside CSS.
Limits and storage
At most 32 images, 20 MiB per image and 20 MiB combined image bytes. A lower
INFLUXION_URL_FETCH_MAX_BYTESfurther limits each image.At most 1 MiB of request JSON and 22 MiB for the complete multipart body, including chunked uploads. Oversized bodies are rejected before multipart parsing. The raw upload and large file parts spool to temporary disk.
Static PNG, JPEG, WebP and UTF-8 SVG are supported. The image bytes are checked for format structure, dimensions and decodability; a declared media type must match, or be
application/octet-stream. Pillow can accept recoverable JPEG scan damage as a decodable image.Raster images are limited to 40 million pixels. Animated images, malformed images and SVG documents containing a DTD or entity declarations are rejected.
Bad names, duplicate names, invalid JSON and raster decode/verification errors return
422; unsupported formats, invalid SVG or mismatched media types return415; byte/pixel limits return413. Multipart parser limits, such as too many parts, return400.
Uploads are staged under a random job-scoped directory in
INFLUXION_PDF_RUNTIME_DIR. Generated storage filenames are independent of
logical names. Celery receives a bundle identifier rather than image bytes.
The app and workers must share that runtime volume, as in the supplied Compose
and Helm configurations; a separate worker machine needs shared storage.
Images are deleted after generation, including failures. Rejected requests, duplicate document IDs and dispatch failures remove their staged images too. Orphans older than 24 hours are removed on app startup and before the next bundle upload; this is opportunistic cleanup, not a background timer. Queued bundle jobs must start within 24 hours. Downloaded PDFs retain the existing short PDF retention policy. There is no permanent image library or image URL.
Invoice and profile examples
The examples use the supplied invoice/profile layouts and named images, with fictitious document data. The profile portrait is a provided example image; replace it when adapting the example.
python docs/examples/generate_bundle.py invoice --dry-run
python docs/examples/generate_bundle.py profile --dry-run
python docs/examples/generate_bundle.py invoice -o output/pdf/invoice.pdf
python docs/examples/generate_bundle.py profile -o output/pdf/profile.pdf
The script reads INFLUXION_CLIENT_ID, INFLUXION_CLIENT_SECRET and optional
INFLUXION_SCOPE from the environment or project .env. The server defaults
to INFLUXION_BASE_URL or http://localhost:8000; override with --base-url.