Retrieving print jobs and files
Once the customer has saved a print job, you can load it in the browser: its data, the designed motive, product preview images and the proofreading PDF. You can also clone a print job to reuse it.
TIP
Example: Get images · source
Load a print job
getPrintJob(printJobGuid) loads a print job of your TronDesigner instance by its GUID. You get the GUID from the printJob events (Events and callbacks) or from your own cart or order.
try {
const printJob = await window.tronDesigner.getPrintJob('3f6c2a8e-9b1d-4c47-a0e2-5d8f1b7c9e21');
console.log(printJob.code, printJob.state, printJob.customProperties);
} catch (error) {
console.error('Print job could not be loaded', error);
}| Result | When |
|---|---|
| Resolves to an IPrintJobDto | The print job was found. Same shape as event.detail of the printJob events, including the customer's comment (on the print job and on each printing) and created / updated as ISO 8601 strings. |
Resolves to undefined | The script is not initialized (missing API key or API URL). |
| Rejects | The request failed: unknown GUID, invalid API key or domain, network error. |
There is no getPrintJobs() method; load print jobs one by one.
Find the GUIDs and codes you need
The file methods need identifiers from the print job object:
| You need | Take it from |
|---|---|
printJobGuid | printJob.printJobGuid, or event.entityGuid of a printJob event |
printingGuid | printJob.printings[i].printingGuid — one printing per print position and technology |
productVariantCode | printJob.product.variants[j].codeSupplier — the supplier's variant code you passed when opening the editor |
The print job also contains ready-made image URLs. They include your API key (apiKey=…), so you can put them straight into an <img src> on your site:
| URL | Shows |
|---|---|
printings[i].printMotive.motiveImage.printJobFileUrl | The motive of the printing (the design without the product) |
printings[i].printMotive.printAreaImages[k].printAreaImageFile.printJobFileUrl | A product image with the motive, for the variant GUIDs in printAreaImages[k].productVariants. type tells which: MOCKUP (with the print-area outline), MOCKUP_CLEAR (without), VISUALIZATION or AI_MOOD_SCENE. |
product.variants[j].previewImageUrl | The product photo of the variant |
Download the motive, preview and proofreading
| Method | Returns |
|---|---|
| getPrintingMotive(printJobGuid, printingGuid) | The motive image of one printing |
| getPrintingImage(printJobGuid, printingGuid, productVariantCode?) | The product preview with the motive, without the print-area outline (MOCKUP_CLEAR). Without productVariantCode, the default variant is used. |
| getProofreading(printJobGuid, templateTag?, language?) | The proofreading PDF |
All three resolve to a Blob. Like getPrintJob(), they resolve to undefined when the script is not initialized and reject when the request fails — for example for a productVariantCode that is not in the print job. When the server has no file for the request, you get an empty Blob (size === 0); check the size before using it.
const td = window.tronDesigner;
const printJob = await td.getPrintJob(printJobGuid);
const { printingGuid } = printJob.printings[0];
const variantCode = printJob.product.variants[0].codeSupplier;
// Show the product preview in an <img>
const preview = await td.getPrintingImage(printJobGuid, printingGuid, variantCode);
if (preview?.size) {
document.querySelector('#preview').src = URL.createObjectURL(preview);
}
// Offer the proofreading PDF as a download
const pdf = await td.getProofreading(printJobGuid);
if (pdf?.size) {
const url = URL.createObjectURL(pdf);
const link = document.createElement('a');
link.href = url;
link.download = `${printJob.code || printJobGuid}.pdf`;
link.click();
setTimeout(() => URL.revokeObjectURL(url), 1000);
}About the proofreading:
getProofreading()generates the PDF on the server on every call. It requires the Proofreadings license feature.templateTagselects a proofreading template, likesetProofreadingTemplateTag()does for the editor. Leave it out for the default template.languageis an ISO-2 code; it defaults to the customer's language.- It doesn't fire the
proofreadingcreatedevent. That event (with the PDF asevent.detail) only fires when the editor generates a proofreading — reuse thatBlobinstead of generating the PDF again.
Object URLs keep the Blob in memory; revoke them with URL.revokeObjectURL() when you no longer need them.
Requests made by these methods
Handy when you debug in the browser's Network tab. All requests go to your data-td-api URL with the TronDesigner-ApiKey header.
| Method | Request |
|---|---|
getPrintJob | GET print-jobs/{printJobGuid} |
getPrintingMotive | GET print-jobs/{printJobGuid}/printings/{printingGuid}/motive-image |
getPrintingImage | GET print-jobs/{printJobGuid}/printings/{printingGuid}/print-area-image?variantCode={productVariantCode} |
getProofreading | POST print-jobs/{printJobGuid}/proofreading?templateTag={templateTag}, language in the TronDesigner-Language header |
clonePrintJob | POST print-jobs/clone/{printJobGuid} |
Clone a print job
clonePrintJob(printJobGuid) copies a print job, including its images, and resolves to the GUID of the copy. Use it for "order again" or to start from an earlier design without changing the original. Open the copy in Edit mode:
const td = window.tronDesigner;
const copyGuid = await td.clonePrintJob(originalPrintJobGuid);
td.setPrintJob(copyGuid, 'Edit').open({ mode: 'dialog' });Because the copy is opened in Edit mode, saving it fires printJob updated, not created.
Do it on your server instead
These methods run in the browser with your public website API key. To process print jobs in your back office — for example to fetch print-ready data after an order, or to be notified even when the customer closes the tab — use the REST API with a server-side key, and Webhooks. The REST API has matching endpoints for the print job, motive image, preview image and proofreading; see Swagger.
See also
- getPrintJob, IPrintJobDto — API reference
- Events and callbacks — get the print job GUID when the customer saves
- Customers and orders — custom properties and order fields in the print job