Skip to content

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.

js
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);
}
ResultWhen
Resolves to an IPrintJobDtoThe 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 undefinedThe script is not initialized (missing API key or API URL).
RejectsThe 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 needTake it from
printJobGuidprintJob.printJobGuid, or event.entityGuid of a printJob event
printingGuidprintJob.printings[i].printingGuid — one printing per print position and technology
productVariantCodeprintJob.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:

URLShows
printings[i].printMotive.motiveImage.printJobFileUrlThe motive of the printing (the design without the product)
printings[i].printMotive.printAreaImages[k].printAreaImageFile.printJobFileUrlA 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].previewImageUrlThe product photo of the variant

Download the motive, preview and proofreading ​

MethodReturns
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.

js
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.
  • templateTag selects a proofreading template, like setProofreadingTemplateTag() does for the editor. Leave it out for the default template.
  • language is an ISO-2 code; it defaults to the customer's language.
  • It doesn't fire the proofreading created event. That event (with the PDF as event.detail) only fires when the editor generates a proofreading — reuse that Blob instead 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.

MethodRequest
getPrintJobGET print-jobs/{printJobGuid}
getPrintingMotiveGET print-jobs/{printJobGuid}/printings/{printingGuid}/motive-image
getPrintingImageGET print-jobs/{printJobGuid}/printings/{printingGuid}/print-area-image?variantCode={productVariantCode}
getProofreadingPOST print-jobs/{printJobGuid}/proofreading?templateTag={templateTag}, language in the TronDesigner-Language header
clonePrintJobPOST 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:

js
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 ​

Czech Republic – The Country for the FutureFunded by the European Union – NextGenerationEUThe project was implemented within the The Country for the Future programme of the Ministry of Industry and Trade and co-financed by the European Union under NextGenerationEU.Support · Examples

Czech Republic – The Country for the FutureFunded by the European Union – NextGenerationEUThe project was implemented within the The Country for the Future programme of the Ministry of Industry and Trade and co-financed by the European Union under NextGenerationEU.Support · Examples