Search Docs
Loading...
Skip to content

To PDF

Export your designs as PDF documents with high compatibility mode and underlayer support for special media printing.

Export to PDF hero image

10 mins
estimated time
Download
StackBlitz
GitHub

PDF provides a universal document format for sharing and printing designs. CE.SDK exports PDF files that preserve vector graphics, support multi-page documents, and include options for print compatibility. You can configure high compatibility mode to ensure consistent rendering across different PDF viewers, and generate underlayers for special media printing like fabric, glass, or DTF transfers.

This guide covers exporting designs to PDF format, configuring high compatibility mode, controlling the quality of rasterized images, generating underlayers with spot colors, and controlling output dimensions.

Export to PDF#

Call engine.block.export() with mimeType: 'application/pdf' to export any block as a PDF document. The method returns a Blob containing the PDF data.

// Export scene as PDF (includes all pages)
const pdfBlob = await engine.block.export(scene, {
mimeType: 'application/pdf'
});

Pass the scene ID from engine.scene.get() to export all pages as a multi-page PDF. You can also pass a single page ID from engine.scene.getCurrentPage() if you only need to export one page.

Track Export Progress#

Large multi-page PDFs take time to write. Pass an onProgress callback to report how far the export has advanced, so you can drive a progress bar instead of an indeterminate spinner.

// Report per-page progress as the PDF is written.
// The callback runs once per page; only PDF exports invoke it.
const pdfBlob = await engine.block.export(scene, {
mimeType: 'application/pdf',
onProgress: (exportedPages, totalPages) => {
console.log(
`Exported ${exportedPages} of ${totalPages} pages`
);
}
});

The callback fires once after each page is serialized into the document, receiving the number of pages exported so far and the total page count. A PNG, JPEG, WebP, TGA or raw export that renders in more than one strip reports its strips to the same callback. When you export through the editor’s built-in export flow, the export dialog already uses this callback to show a per-page progress bar for PDF exports.

Cancel a Running Export#

Pass an abortSignal to stop an export that the user no longer waits for. The promise rejects, and no file is produced.

// Abort a running export. Wire `controller.abort()` to your own
// Cancel button; the timeout here only keeps the example short.
const controller = new AbortController();
setTimeout(() => controller.abort(), 500);
try {
const pdfBlob = await engine.block.export(scene, {
mimeType: 'application/pdf',
abortSignal: controller.signal
});
await cesdk.utils.downloadFile(pdfBlob, 'application/pdf');
} catch (error) {
// A cancelled export produces no file.
console.log('Export cancelled', error);
}

For a multi-page PDF the engine stops at the next page boundary, so the pages that are still queued are never rendered. Every other export stops at once, for example while it waits for an image to load. Reuse of a controller is not possible: an AbortController signals only once, so create a new one for each export.

Export Animated Pages at a Cover Time#

A page of an animated or video scene exports at its playback time. So each page of a slide deck shows the moment where its playhead rests. Give each page a cover time to export a fixed moment instead, like the poster frame of a slide.

// Show each page at 2 seconds, whatever its playback time is.
// The scene keeps the cover times, so later exports use them too.
for (const coverPage of engine.block.findByType('page')) {
engine.block.setDouble(coverPage, 'playback/coverTime', 2);
engine.block.setBool(
coverPage,
'playback/coverTimeEnabled',
true
);
}
const pdfBlob = await engine.block.export(scene, {
mimeType: 'application/pdf'
});

Set playback/coverTime to the time in seconds on the page, and playback/coverTimeEnabled to true. Each page exports at its own cover time, and its playback time does not change. A cover time after the end of the page shows the end of the page. The scene saves both properties, and undo puts them back.

The cover time also applies to PNG, JPEG, WebP and SVG exports of the page or its scene, and to the preview image of a saved archive. An MP4 export of the page uses it for its cover, unless coverTimeOffset sets the cover. An export of a single block on the page still uses the playback time of the page.

Export Large Documents#

PDF exports are streamed internally: the engine writes the document in small chunks, so it never holds the finished file in its memory. Where the browser supports the origin private file system, engine.block.export() also stages those chunks in a temporary file on disk and resolves with a Blob backed by that file. Memory usage then stays flat at chunk size for the whole export, no matter how large the document gets. Where it does not, the Blob is assembled in memory instead. This all happens automatically, and the resolved Blob has the same content and type either way.

Check engine.editor.getCapabilityState('tempFileStorage') to see which path the current browser takes. The engine measures it while it starts, so it answers 'supported' or 'unsupported' as soon as CreativeEngine.init() resolves.

The temporary file has to outlive the Blob that it backs, so it is not deleted when the export finishes. CE.SDK collects the staging files of earlier page loads for you. Until then they count towards the storage quota of the origin.

A failed staged export reports the ENCODE.PDF_STAGING_WRITE_FAILED code rather than returning a truncated file, for example when the device has no space left for the temporary file. The export also fails with this code when the temporary storage stops responding to its writes for 30 seconds while the page is active, rather than waiting without a limit.

Configure High Compatibility Mode#

Enable exportPdfWithHighCompatibility to rasterize complex elements like gradients with transparency at the scene’s DPI. This ensures consistent rendering across all PDF viewers.

// Enable high compatibility mode for consistent rendering across PDF viewers
// This rasterizes complex elements like gradients with transparency at scene DPI
const pdfBlob = await engine.block.export(scene, {
mimeType: 'application/pdf',
exportPdfWithHighCompatibility: true
});

Use high compatibility mode when:

  • Designs contain gradients with transparency
  • Effects or blend modes render inconsistently across viewers
  • Maximum compatibility matters more than vector precision

High compatibility mode increases file size because complex elements are converted to raster images rather than remaining as vectors.

Control the Size of Rasterized Images#

When exportPdfWithHighCompatibility is false, CE.SDK embeds the original data of unmodified JPEG images directly into the PDF. This keeps exports of photo-heavy documents such as photo books fast and small, because the photos are not decoded and encoded again.

CE.SDK must rasterize images that it cannot embed directly, for example images with effects or blurs applied, or every bitmap image when high compatibility mode is enabled. By default these images are encoded losslessly. Set pdfImageQuality to a value below 1.0 to encode them as lossy JPEG instead, which produces much smaller files.

const pdfBlob = await engine.block.export(page, {
mimeType: 'application/pdf',
pdfImageQuality: 0.85
});

Valid values are greater than 0 and at most 1.0. The default of 1.0 keeps the lossless encoding, in the same way as webpQuality. Images that are embedded as their original JPEG data are never encoded again, so this option does not change them.

Generate Underlayers for Special Media#

Underlayers provide a base ink layer (typically white) for printing on transparent or non-white substrates like fabric, glass, or acrylic. The underlayer sits behind your design elements and provides opacity on transparent materials.

Define the Underlayer Spot Color#

Before exporting, define a spot color that represents the underlayer ink. The RGB values provide a preview representation in PDF viewers.

// Define the underlayer spot color before export
// RGB values (0.8, 0.8, 0.8) provide a preview representation
engine.editor.setSpotColorRGB('RDG_WHITE', 0.8, 0.8, 0.8);

The spot color name (e.g., 'RDG_WHITE') must match your print provider’s requirements. Common names include RDG_WHITE for Roland DG printers and White for other systems.

Export with Underlayer Options#

Configure the underlayer spot color name and optional offset. The underlayerOffset adjusts the underlayer size in design units—negative values shrink it inward to prevent visible edges from print misalignment (trapping). Thin text and lines can lose their underlayer when the offset shrinks it. Set underlayerMinFeatureWidth to keep each thin part at least that wide, in the same unit as underlayerOffset.

// Export with underlayer for special media printing
const pdfBlob = await engine.block.export(scene, {
mimeType: 'application/pdf',
exportPdfWithHighCompatibility: true,
exportPdfWithUnderlayer: true,
underlayerSpotColorName: 'RDG_WHITE',
// Negative offset shrinks underlayer to prevent visible edges
underlayerOffset: -2.0
});

The underlayer is generated automatically from the contours of all design elements on the page. Elements with transparency will have proportionally reduced underlayer opacity.

Add Printer’s Marks#

A print shop needs to see where to cut, and a press operator needs a target to align the plates against. Set exportPdfWithCropMarks to draw the four pairs of corner lines that mark the cut, and exportPdfWithRegistrationMarks to draw a bullseye at the middle of each page edge. On a page with page slices, such as a tri-fold leaflet, set exportPdfWithFoldMarks to mark each fold. Crop marks draw no fold marks. All three options default to false, so an export that does not ask for marks is unchanged.

const pdfBlob = await engine.block.export(page, {
mimeType: 'application/pdf',
exportPdfWithCropMarks: true,
exportPdfWithFoldMarks: true,
exportPdfWithRegistrationMarks: true,
printMarkOffset: 6,
printMarkWidth: 0.25,
cropMarkLength: 15
});

Every mark type is painted in the PDF registration colorant All, so it appears on every separation, and each is knocked out in white underneath so it stays legible over dark artwork.

printMarkOffset and printMarkWidth are shared by every mark type, and cropMarkLength sets one corner line. The offset and the length are in design units, so the offset is directly comparable with the page bleed and the sheet grows by the sum of the two. The weight is in points, the unit a print shop states a stroke weight in.

The offset is measured from the trim, so a small offset places a mark inside the bleed, which the knife removes anyway. A negative offset falls back to the 6 pt default, and 0 places a mark on the trim edge.

Marks grow the exported page by the offset plus the equivalent of 15 points on each side, or by the offset plus cropMarkLength when that is longer. The artwork does not move, and the TrimBox and BleedBox keep describing the same physical rectangles. A page whose trim is not a rectangle gets no marks and no larger page.

A fold is at the start of each visible page slice that follows another visible page slice. With exportPdfWithFoldMarks, each fold gets a fold mark pair: a solid line on the extension of the fold, one on each side of the page. A fold mark uses the offset, weight and length of the crop marks. A fold never moves or removes a registration mark. At a fold in the middle of a page edge, the fold mark lies over the registration mark. Fold marks grow the exported page on the same terms as crop marks. With both options, they share one margin. A page without a fold gets no fold marks and no larger page. A printer wants the whole sheet of a folded product, with the bleed, the crop marks and the fold marks. Folded Products and Spreads shows how to build one.

Marks From the Print Setup Panel#

In the editor, users choose the marks in the Print Setup panel, opened from the Print section of the document inspector. The section appears when the ly.img.page feature offers its bleedMargin option, or the crop or registration option inside printMarks.

When users choose crop marks there, the editor also asks for fold marks, so a folded product gets both. A mark option that you pass to cesdk.utils.export replaces only that option. Your exportPdfWithCropMarks never turns on fold marks, so pass exportPdfWithFoldMarks for them.

Export Each Page Slice as a PDF Page#

Set exportPdfPageSlices to export each page slice of a page as its own PDF page, in reading order. The option applies to the PDF export of a scene or of one page, and defaults to false.

const pdfBlob = await engine.block.export(page, {
mimeType: 'application/pdf',
exportPdfPageSlices: true
});

Each PDF page holds the part of the page inside the page slice, with the bleed of the page on all four sides. With a bleed or printer’s marks, it has a TrimBox and a BleedBox, as a page has. A PDF page of one page slice gets no fold marks.

A hidden page slice gets no PDF page. It keeps its room in the layout, and the content it owns shows in no PDF page. An export of one page whose page slices are all hidden gives the whole page as one PDF page. A page that is not included in the export keeps its PDF pages, without content. A page without page slices stays one PDF page.

To export one page slice alone, pass the page slice to the export call, in any format. The result is the part of the page inside the page slice, with the bleed of the page on all four sides.

Export at Target Dimensions#

Use targetWidth and targetHeight to control the exported PDF dimensions in pixels. The block renders large enough to fill the target size while maintaining aspect ratio.

// Export with specific dimensions for print output
const pdfBlob = await engine.block.export(scene, {
mimeType: 'application/pdf',
targetWidth: 2480, // A4 at 300 DPI (210mm)
targetHeight: 3508 // A4 at 300 DPI (297mm)
});

For print output, calculate the target dimensions based on your desired DPI:

  • A4 at 300 DPI: 2480 × 3508 pixels
  • Letter at 300 DPI: 2550 × 3300 pixels

Built-in Export Action#

Run the exportDesign action to execute the default export flow programmatically.

// Run built-in export with PDF format
await cesdk.actions.run('exportDesign', {
mimeType: 'application/pdf'
});

This executes the registered export action, which handles the complete export process including format selection and file download.

Customize Export Action#

Register a custom exportDesign action to apply PDF-specific options automatically. This lets you set defaults like high compatibility mode that apply whenever the export action runs.

// Register a custom export action with PDF-specific options
cesdk.actions.register('exportDesign', async () => {
// Export the scene block to include all pages in the PDF
const scene = engine.scene.get()!;
// Merge PDF-specific defaults with provided options
const blob = await engine.block.export(scene, {
mimeType: 'application/pdf',
exportPdfWithHighCompatibility: true
});
await cesdk.utils.downloadFile(blob, 'application/pdf');
});

The custom action merges your PDF defaults with any options passed when the action runs. This approach centralizes export configuration and ensures consistent behavior across your application.

Download Export#

Use cesdk.utils.downloadFile() to trigger the browser’s download dialog for the exported blob.

// Download using CE.SDK utils
await cesdk.utils.downloadFile(pdfBlob, 'application/pdf');

Pass the blob and MIME type to prompt the user to save the file locally.

PDF Export Options#

Option Description
mimeType Output format. Must be 'application/pdf'.
exportPdfWithHighCompatibility Rasterize complex elements at scene DPI for consistent rendering. Defaults to true.
pdfImageQuality Encoding quality for images that CE.SDK has to rasterize. Values below the default of 1.0 encode them as lossy JPEG.
exportPdfWithUnderlayer Generate an underlayer from design contours. Defaults to false.
underlayerSpotColorName Spot color name for the underlayer ink. Required when exportPdfWithUnderlayer is true.
underlayerOffset Size adjustment in design units. Negative values shrink the underlayer inward.
underlayerMinFeatureWidth Smallest width, in design units, that a thin part keeps when a negative underlayerOffset shrinks the underlayer. 0 turns it off. Defaults to 0.
exportPdfWithCropMarks Draw the four pairs of corner lines that show a print shop where to cut. Crop marks draw no fold marks. Defaults to false.
exportPdfWithFoldMarks On a page with page slices, draw a fold mark pair at each fold. Defaults to false.
exportPdfWithRegistrationMarks Draw a bullseye target at the middle of each page edge, which a press operator aligns the plates by. Defaults to false.
exportPdfPageSlices Export each page slice of a page as its own PDF page, in reading order. Defaults to false.
printMarkOffset Distance in design units from the trim to the nearest edge of any mark, so it is comparable with the page bleed. Shared by every mark type. Defaults to 6 pt.
printMarkWidth Stroke weight in points of any mark, the unit a print shop states a weight in. Shared by every mark type. Defaults to 0.25.
cropMarkLength Length in design units of one crop mark line and of one fold mark line, the same unit as printMarkOffset. Defaults to 15 pt.
targetWidth Target output width in pixels. Alone, the height follows from the aspect ratio.
targetHeight Target output height in pixels. Alone, the width follows from the aspect ratio.
onProgress Callback invoked once per page during PDF export with (exportedPages, totalPages). A raster export of more than one strip reports its strips to it.
pdfChunkSize Upper bound in bytes for a single chunk the PDF encoder hands to the export. Tunes the memory the export holds while it runs; it does not change the returned document. Defaults to an engine-chosen 512 KiB. Other values are clamped to 4 KiB to 64 MiB.
outputColorSpace Color space of the PDF output, 'RGB' (default) or 'CMYK'. 'CMYK' writes CMYK colors as DeviceCMYK, and spot colors as Separations with a DeviceCMYK alternate. RGB colors stay RGB with 'Off', and convert with the other modes. See Export for Printing.
outputProfileMode What the export does with the document’s Output profile: 'Off' (default), 'Convert' converts every solid color and image into it, 'Assign' keeps the colors already in its space and converts the others. See Export for Printing.
embedProfiles Write the Output profile into the PDF as the OutputIntent. Defaults to false.
preserveBlack Keep black pure while colors convert: exact RGB black becomes K-only black in a CMYK output, and K-only black becomes exact RGB black in an RGB output. Defaults to false.
abortSignal Signal that cancels the export. A multi-page PDF export stops at the next page boundary.

API Reference#

Method Description
engine.block.export(blockId, options) Export a block as PDF with format and compatibility options
engine.editor.setSpotColorRGB(name, r, g, b) Define a spot color for underlayer ink
engine.block.setDouble(page, 'playback/coverTime', seconds) Set the moment that a still export of the page shows
engine.block.setBool(page, 'playback/coverTimeEnabled', true) Export the page at its cover time instead of its playback time
engine.scene.get() Get the scene for multi-page PDF export
engine.scene.getCurrentPage() Get the current page for single-page export
cesdk.actions.run() Runs a built-in action like exportDesign
cesdk.actions.register() Registers a custom action to override default behavior
cesdk.utils.downloadFile() Triggers browser download dialog for a blob

Next Steps#