v1.7.471

SuperPrint API

API SuperPrint

SuperPrint exposes a scripting API on the global object window.SuperPrint inside the editor. Use it from the browser console, from a <script> you inject, or from an automation tool driving the page. It lets you build layouts programmatically: add text, shapes and images, manage pages, load and save documents, export PDF, and trigger AI generation.

SuperPrint expose une API de script sur l'objet global window.SuperPrint à l'intérieur de l'éditeur. Utilisez-la depuis la console du navigateur, depuis un <script> que vous injectez, ou depuis un outil d'automatisation qui pilote la page. Elle permet de construire des maquettes par programme : ajouter du texte, des formes et des images, gérer les pages, charger et enregistrer des documents, exporter en PDF et déclencher la génération par IA.

Where to run it. Open SuperPrint Editor, then press F12 to open the console. The API only exists after a document is open (the editor must be initialised).
Où l'exécuter. Ouvrez SuperPrint Editor, puis appuyez sur F12 pour ouvrir la console. L'API n'existe qu'une fois un document ouvert (l'éditeur doit être initialisé).

Quick start

Prise en main

// Afficher la surface disponible
console.log(Object.keys(window.SuperPrint));

// Un carton d'invitation, en millimètres
SuperPrint.addRect(0, 0, 210, 297, { fill: '#f7f3ec' });
SuperPrint.addRect(20, 20, 170, 6,  { fill: '#0c0c0f' });
SuperPrint.addText(20, 40, 'Ouverture le 14 mars', { fontSize: 28, fontWeight: 'bold' });
SuperPrint.addText(20, 70, 'Galerie du Port, 12 quai Sud', { fontSize: 13 });

SuperPrint.exportPDF({ quality: 'hd', colorMode: 'cmyk' });
Units. All coordinates and sizes are in millimetres, relative to the top-left corner of the page. They are converted to canvas pixels internally.
Unités. Toutes les coordonnées et tailles sont en millimètres, depuis le coin supérieur gauche de la page. Elles sont converties en pixels du canevas en interne.

Content methods

Méthodes de contenu

addText

SuperPrint.addText(x, y, text, options?) → fabric.Textbox

options: width (mm, default 100), fontSize, fontFamily, fontWeight, fill, textAlign.

options : width (mm, défaut 100), fontSize, fontFamily, fontWeight, fill, textAlign.

SuperPrint.addText(20, 20, 'Titre', { fontSize: 24, fontWeight: 'bold', width: 120 });
The first three arguments are required and validated: passing a non-string text or a non-numeric coordinate throws an explicit error.
Les trois premiers arguments sont obligatoires et contrôlés : un texte non-chaîne ou une coordonnée non-numérique lève une erreur explicite.

addRect

SuperPrint.addRect(x, y, width, height, options?) → fabric.Rect

options: fill (default #cccccc), stroke, strokeWidth.

options : fill (défaut #cccccc), stroke, strokeWidth.

SuperPrint.addRect(20, 20, 60, 40, { fill: '#1a1a1a', stroke: 'none', strokeWidth: 0 });

addCircle

SuperPrint.addCircle(x, y, radius, options?)

options: fill, stroke, strokeWidth. x / y position the centre.

options : fill, stroke, strokeWidth. x / y positionnent le centre.

addEllipse

SuperPrint.addEllipse(x, y, rx, ry, options?)

options: fill, stroke, strokeWidth. rx / ry are the two radii, in mm.

options : fill, stroke, strokeWidth. rx / ry sont les deux rayons, en mm.

addImage

SuperPrint.addImage(x, y, imageUrl, options?) → Promise

options: scaleX, scaleY. Returns a Promise resolving to the created image — await it before measuring or exporting.

options : scaleX, scaleY. Renvoie une promesse résolue avec l'image créée — attendez-la avant de mesurer ou d'exporter.

await SuperPrint.addImage(20, 120, 'photo.jpg', { scaleX: 0.5, scaleY: 0.5 });

generateGrid

SuperPrint.generateGrid(...)

Creates a set of layout guides on the current page (columns / rows / gutters).

Crée un jeu de repères de mise en page sur la page courante (colonnes / lignes / gouttières).

bulkText

SuperPrint.bulkText(...)

Batch text creation — inserts several text blocks in one call, useful for catalogues and lists.

Création de textes en lot — insère plusieurs blocs en un seul appel, pratique pour les catalogues et les listes.

Page & document methods

Méthodes page & document

getPages

SuperPrint.getPages() → Array

Returns one entry per page: { index, objects, active }.

Renvoie une entrée par page : { index, objects, active }.

setPage

SuperPrint.setPage(pageIndex) → Boolean

Switches the active page. Returns false if the index is out of range.

Change la page active. Renvoie false si l'index est hors limites.

loadProject

SuperPrint.loadProject(jsonData)

Loads a project from a parsed JSON object (the same structure as the .json export).

Charge un projet depuis un objet JSON déjà analysé (même structure que l'export .json).

saveProject

SuperPrint.saveProject() → Object

Flushes all pages and returns the serialised project object. You can JSON.stringify() it and store it wherever you like.

Synchronise toutes les pages et renvoie l'objet projet sérialisé. Vous pouvez le passer à JSON.stringify() et le stocker où vous voulez.

exportPDF

SuperPrint.exportPDF(options?) → confirmExport()

options: quality (hd = 300 DPI), colorMode (rgb | cmyk). The options pre-set the export dialog, then the export runs.

options : quality (hd = 300 DPI), colorMode (rgb | cmyk). Les options pré-règlent la boîte d'export, puis l'export se lance.

SuperPrint.exportPDF({ quality: 'hd', colorMode: 'cmyk' });

aiGenerate

SuperPrint.aiGenerate(prompt)

Sends a natural-language prompt to the configured AI engine (SP213) and builds the resulting layout on the canvas. Requires an API key configured in the AI panel.

Envoie une consigne en langage naturel au moteur IA configuré (SP213) et construit la maquette résultante sur le canevas. Nécessite une clé API configurée dans le panneau IA.

SuperPrint.aiGenerate('A4 poster for a jazz festival, deep blue and gold, bold title');

Full reference

Référence complète

MethodMéthode ReturnsRenvoie PurposeRôle
addText(x, y, text, options)Textbox Adds a text blockAjoute un bloc texte
addRect(x, y, w, h, options)Rect Adds a rectangleAjoute un rectangle
addCircle(x, y, r, options)Circle Adds a circleAjoute un cercle
addEllipse(x, y, rx, ry, options)Ellipse Adds an ellipseAjoute une ellipse
addImage(x, y, url, options)Promise Adds an image (async)Ajoute une image (asynchrone)
generateGrid(...) Creates layout guidesCrée des repères de mise en page
bulkText(...) Batch text creationCréation de textes en lot
getPages()Array Lists the pagesListe les pages
setPage(i)Boolean Switches the active pageChange la page active
loadProject(json) Loads a projectCharge un projet
saveProject()Object Serialises the projectSérialise le projet
exportPDF(options) Exports the PDFExporte le PDF
aiGenerate(prompt) Generates a layout with AIGénère une maquette par IA

Example: a data-driven catalogue

Exemple : un catalogue piloté par des données

const products = [
  { nom: 'Vase Kano',   prix: '140 EUR', ref: 'VK-014' },
  { nom: 'Coupe Sora',  prix: '95 EUR',  ref: 'CS-009' },
  { nom: 'Plateau Ito', prix: '180 EUR', ref: 'PI-021' },
  { nom: 'Bougeoir Mei',prix: '65 EUR',  ref: 'BM-007' }
];

SuperPrint.addText(15, 18, 'COLLECTION HIVER 2026', { fontSize: 11, fill: '#C7382B' });
SuperPrint.addText(15, 26, 'Objets en pierre et laiton', { fontSize: 30, fontWeight: 'bold' });

products.forEach((p, i) => {
  const col = i % 2, row = Math.floor(i / 2);
  const x = 15 + col * 92, y = 78 + row * 96;
  SuperPrint.addRect(x, y, 88, 56, { fill: '#EFE9DD', stroke: 'none' });
  SuperPrint.addText(x, y + 60, p.nom,  { fontSize: 14, fontWeight: 'bold' });
  SuperPrint.addText(x, y + 68, p.ref,  { fontSize: 8 });
  SuperPrint.addText(x + 60, y + 60, p.prix, { fontSize: 20, fontWeight: 'bold', fill: '#C7382B' });
});

Combine this with SuperTyPo for type work, the SP213 Studio for AI-first layouts, and the documentation for the interface itself.

À combiner avec SuperTyPo pour le travail typographique, le studio SP213 pour les maquettes pilotées par IA, et la documentation pour l'interface elle-même.