Printing Features

Design on Web includes a comprehensive set of features for the printing industry. These allow you to build product-aware design editors where users create artwork for physical products like t-shirts, packaging boxes, labels, and business cards.

Product Configuration System

The product configuration system defines how the editor maps to a physical product. Each product has one mockup image, a print area (the region on the mockup where the design appears), and canvas dimensions in centimeters.

When a product config is applied, the editor sets up the background mockup, positions the canvas as a “window” on the mockup, and optionally loads a dieline overlay.

Define and apply a product configtypescript
import { EditorEngine } from '@design-on-web/core';
import type { ProductConfig, PrintSizeOption } from '@design-on-web/core';

// Define a t-shirt product
const tshirtProduct: ProductConfig = {
  id: 'tshirt-white-front',
  name: 'White T-Shirt — Front',
  mockupImage: '/assets/mockups/tshirt-white.png',
  printArea: { x: 280, y: 180, width: 520, height: 620 },
  canvasSizeCm: { width: 30, height: 40 },
  dielineImage: '/assets/dielines/tshirt-safe-zone.svg',
};

// Define available print sizes
const printSizes: PrintSizeOption[] = [
  { label: 'A4', widthCm: 21, heightCm: 29.7 },
  { label: 'A3', widthCm: 29.7, heightCm: 42 },
  { label: 'Letter', widthCm: 21.59, heightCm: 27.94 },
];

// Apply the product config with a default print size
await engine.applyProductConfig(tshirtProduct, printSizes[0]);

// The editor now shows:
// - T-shirt mockup image behind the canvas
// - Canvas sized and positioned to match the print area
// - Dieline overlay (safe zone) on top of the design

Changing Print Size

Users can switch between standard print sizes (A4, A3, Letter, or custom). The canvas dimensions are recalculated based on the ratio between the physical canvas size and the selected print size.

Switch print sizestypescript
// User selects a different print size from dropdown
engine.changePrintSize({ label: 'A3', widthCm: 29.7, heightCm: 42 });

// Canvas dimensions are recalculated based on the product's
// canvasSizeCm and the new print size ratios

// Get the active product config
const config = engine.getActiveProductConfig();
console.log(config?.name); // "White T-Shirt — Front"

// Clear everything when switching to a different product
engine.clearProductConfig();

ProductConfig Interface

NameTypeDefaultDescription
id*stringUnique identifier for the product.
name*stringDisplay name shown in the UI.
mockupImage*stringURL or path to the product mockup image.
printArea*{ x, y, width, height }Position and size (in pixels) of the print area on the mockup image.
canvasSizeCm*{ width, height }Physical canvas dimensions in centimeters.
dielineImagestringOptional URL or path to a dieline SVG/image overlay (centered on canvas).
overlayUrlstringOptional foreground overlay PNG (e.g. chip/logo). Same dimensions as mockup, rendered on top of design with mockup transform.
overlayOpacitynumberOpacity of the foreground overlay (0 to 1). Default: 0.8.

PrintSizeOption Interface

NameTypeDefaultDescription
label*stringDisplay label (e.g., 'A4', 'A3', 'Custom').
widthCm*numberWidth in centimeters.
heightCm*numberHeight in centimeters.
💡
Admin-defined products
Product configurations are typically defined by platform admins, not end users. Your application would store these configs in a database and load the appropriate one when the user selects a product to design.

Visual Canvas Architecture

The editor uses a visual canvas approach: the Fabric.js canvas operates at a small visual size (~600px longest side) regardless of the actual print dimensions. An export multiplier is calculated to upscale the output to the target DPI (300 DPI by default).

  • VISUAL_MAX = 600 — the longest canvas side in pixels
  • A 25×35cm product becomes ~429×600px in the editor
  • Export multiplier = 1 / (600 / max(printW, printH)) — e.g., 6.89x
  • Zoom is capped at 100% so the canvas never appears larger than its visual size
  • Container should be at least 600px wide for optimal editing experience
ℹ️
DPI guard
When the export multiplier is active, uploaded images are automatically scaled down to fit within the DPI limit (150 DPI at export resolution). Interactive scaling is also clamped — see Image Effects for details.

Print Area Ratio

The printAreaWidth and printAreaHeight must match the ratio of printWidthCm / printHeightCm. If the ratios don't match, the mockup will appear stretched. The simplest approach: set printAreaWidth and calculate printAreaHeight = printAreaWidth × (printHeightCm / printWidthCm).

Background Mockup

A background mockup is an image rendered behind the design canvas. It shows the physical product shape so users can preview their design in context (e.g., seeing their artwork on a t-shirt or mug).

  • Non-exportable — excluded from all export formats
  • Non-selectable — users cannot move, resize, or interact with it
  • Configurable opacity for adjusting visual prominence
Background mockuptypescript
// Set a background mockup manually (without product config)
await engine.setBackgroundMockup('/assets/packaging-box.png', {
  opacity: 0.8,
});

// The mockup renders behind all design objects
// It is NOT included in exports (PNG, PDF, SVG, etc.)
// It is NOT selectable or movable by the user

// Adjust opacity without reloading the image
engine.updateBackgroundMockup({ opacity: 0.5 });

// Remove when switching products
engine.removeBackgroundMockup();

Methods

NameTypeDefaultDescription
setBackgroundMockup(src, options?)Promise<void>Loads an image and places it behind the canvas. Options: { opacity?: number }.
removeBackgroundMockup()voidRemoves the background mockup.
updateBackgroundMockup(options)voidUpdates mockup properties (e.g., opacity) without reloading the image.

Foreground Overlay

Some products have elements that must appear on top of the user's design — like the chip and logo on an e-money card, or a window cut-out on packaging. Use overlayUrl in the product config to add a transparent PNG that renders above all design objects.

  • Must be the same dimensions as the mockup image
  • Uses the same transform as the background mockup (auto-aligned)
  • Non-selectable and non-exportable
  • Stays on top even when new objects are added or reordered
💡
Two-layer mockup workflow
Split your product mockup into two files: a background (the product surface, e.g. plain card) and a foreground overlay (chip, logo, fixed elements as transparent PNG). Set mockupUrl for background and overlayUrl for foreground.

Dieline Overlay

A dieline overlay is an image or SVG rendered on top of the design canvas. It shows cut lines, fold lines, bleed zones, and safe zones — essential for packaging and label products where the printed output will be die-cut.

  • Non-exportable — excluded from all export formats
  • Toggleable visibility — hide for clean preview, show for editing guidance
  • Supports SVG (recommended) or raster images
Dieline overlaytypescript
// Set a dieline overlay (cut/fold/bleed lines)
await engine.setDielineOverlay('/assets/dielines/box-tuck-end.svg', {
  opacity: 0.6,
});

// The overlay renders on TOP of all design objects
// It is NOT included in exports
// It is NOT selectable or movable

// Toggle visibility (useful for "preview" mode)
engine.toggleDielineVisibility(false); // hide — user sees clean design
engine.toggleDielineVisibility(true);  // show — user sees guides again
engine.toggleDielineVisibility();      // toggle current state

// Update options
engine.updateDielineOverlay({ opacity: 0.3 });

// Remove entirely
engine.removeDielineOverlay();

Methods

NameTypeDefaultDescription
setDielineOverlay(src, options?)Promise<void>Loads an SVG or image and places it on top of the canvas. Options: { opacity?: number }.
removeDielineOverlay()voidRemoves the dieline overlay.
updateDielineOverlay(options)voidUpdates overlay properties without reloading.
toggleDielineVisibility(visible?)voidToggles visibility. Pass true/false to set explicitly, or omit to toggle.
ℹ️
SVG recommended for dielines
Use SVG format for dieline overlays. SVGs scale cleanly at any zoom level and keep the file size small. Color-code different line types (cut, fold, bleed, safe zone) for clarity.

Dieline Generator

For packaging products, you can auto-generate a tuck-end box dieline from physical dimensions (length, width, height in cm). The generator produces a complete SVG with color-coded lines for each zone.

Auto-generate a box dielinetypescript
import { generateTuckEndBoxDieline } from '@design-on-web/core';

// Generate a tuck-end box dieline from physical dimensions
const svg = generateTuckEndBoxDieline({
  length: 10,   // cm — box length (P)
  width: 6,     // cm — box width (L)
  height: 15,   // cm — box height (T)
  bleed: 0.3,   // cm — bleed zone outside cut lines
  safeZone: 0.5, // cm — safe zone inside cut lines
  dpi: 300,     // resolution for px conversion
});

// svg is a complete SVG string with color-coded lines:
// - Red (#FF0000): cut lines
// - Blue (#0000FF): fold lines
// - Orange (#FF8C00): glue flap areas
// - Magenta (#FF00FF): bleed zone boundary
// - Green (#00AA00): safe zone boundary

// Use it directly as a dieline overlay
const blob = new Blob([svg], { type: 'image/svg+xml' });
const url = URL.createObjectURL(blob);
await engine.setDielineOverlay(url, { opacity: 0.5 });

generateTuckEndBoxDieline Options

NameTypeDefaultDescription
length*numberBox length in centimeters (P dimension).
width*numberBox width in centimeters (L dimension).
height*numberBox height in centimeters (T dimension).
bleednumber0.3Bleed zone width in centimeters.
safeZonenumber0.5Safe zone inset in centimeters.
dpinumber300Resolution for cm-to-pixel conversion.

Generated SVG Line Colors

NameTypeDefaultDescription
Cut lines#FF0000 (red)Where the material will be cut.
Fold lines#0000FF (blue)Where the material will be folded.
Glue areas#FF8C00 (orange)Glue flap regions for assembly.
Bleed zone#FF00FF (magenta)Boundary of the bleed area — artwork must extend to this line.
Safe zone#00AA00 (green)Boundary of the safe zone — keep important content inside this line.

Complete Workflow Example

This example shows the full printing workflow: defining a product, applying the config, generating a dieline, and exporting the final design.

End-to-end packaging editortypescript
// Complete printing workflow: packaging box editor

// 1. Admin defines the product configuration
const boxProduct: ProductConfig = {
  id: 'tuck-end-box-small',
  name: 'Tuck End Box — Small',
  mockupImage: '/assets/mockups/tuck-end-box.png',
  printArea: { x: 50, y: 80, width: 900, height: 700 },
  canvasSizeCm: { width: 32, height: 25 },
};

// 2. Apply product config
await engine.applyProductConfig(boxProduct, {
  label: 'Custom',
  widthCm: 32,
  heightCm: 25,
});

// 3. Auto-generate dieline from box dimensions
const dieline = generateTuckEndBoxDieline({
  length: 10, width: 6, height: 15,
  bleed: 0.3, safeZone: 0.5, dpi: 300,
});
const dielineUrl = URL.createObjectURL(
  new Blob([dieline], { type: 'image/svg+xml' })
);
await engine.setDielineOverlay(dielineUrl, { opacity: 0.5 });

// 4. User designs on the canvas...

// 5. Toggle dieline off for a clean preview
engine.toggleDielineVisibility(false);

// 6. Export the design (mockup + dieline excluded automatically)
const pdfBlob = await engine.exportAs('pdf', { multiplier: 2 });
💡
Export excludes visual guides
When calling engine.exportAs(), the background mockup and dieline overlay are automatically excluded. The exported file contains only the user's design — ready for print production.