polotno icon

polotno

Export Polotno JSON into images and pdf files. NodeJS package to work with Polotno SDK

Overview

This node converts JSON data describing graphical content into various output formats such as PNG, GIF, PDF, or MP4 video. It is useful for automating the generation of images, animations, documents, or videos from structured JSON design data. Typical use cases include creating dynamic graphics, exporting design previews, generating marketing materials, or producing video content programmatically.

For example, a user can input a JSON design specification and receive a rendered PNG image or an animated GIF without manual graphic design steps. The node supports modifying the JSON before rendering and configuring browser options to control rendering behavior.

Properties

Name Meaning
json 路径 Path to the JSON file containing the design data to be processed.
json参数修改 JSON array of parameter modifications to apply to the loaded JSON data before rendering. Each modification replaces occurrences of a specified name with a new value in the JSON string.
输出格式 Output format of the rendered result. Options: png, gif, pdf, mp4. Determines whether the output is a static image, animation, document, or video.
附加属性 Additional rendering attributes controlling text overflow and resizing behavior:
- textVerticalResizeEnabled (boolean): Allow vertical resizing of text.
- textSplitAllowed (boolean): Allow splitting words across lines.
- textOverflow (option): Behavior when text overflows, options are change-font-size, resize, or ellipsis.
浏览器配置 Browser configuration options:
- args (boolean): Whether to add recommended container environment parameters for Puppeteer.
- browerless (wsEndpoint string): WebSocket endpoint URL for connecting to a remote browser instance.
- url (string): URL used if connecting via WebSocket.

Output

The node outputs one item per input JSON, each containing:

  • json: An empty object (no specific JSON output).
  • binary.data: The rendered output file encoded as binary data.
    • For png, gif, and pdf formats, this is the base64-encoded image or document.
    • For mp4, this is the base64-encoded video file.

The binary data is prepared so it can be used downstream in workflows that accept binary files, such as saving to disk or uploading.

Dependencies

  • Requires the external service "polotno-node" with an API key hardcoded in the source (key: "nFA5H9elEytDyPyvKL7T").
  • Uses Puppeteer Core for browser automation, optionally connecting to a remote browser via WebSocket.
  • Uses Node.js fs module for reading JSON files and temporary video files.
  • Uses an additional package for video generation from JSON (polotno-node/video-parallel).

No explicit n8n credential or environment variable configuration is shown, but the API key is embedded in the code.

Troubleshooting

  • File Reading Errors: If the JSON path is incorrect or the file is inaccessible, the node will fail reading the JSON file. Ensure the path is correct and accessible by n8n.
  • JSON Parsing Errors: Invalid JSON in the parameters or the JSON file will cause parsing failures. Validate JSON syntax before running.
  • API Key Issues: The API key is hardcoded; if the service changes or limits usage, rendering may fail. Consider updating or externalizing the key.
  • Browser Connection Failures: When using remote browser connection (wsEndpoint), ensure the WebSocket URL is reachable and valid.
  • Output Format Unsupported: Selecting an unsupported output format or misconfiguration may cause errors.
  • Temporary File Handling: For MP4 output, the node writes and deletes a temporary file out.mp4. Permission issues or concurrent executions might cause conflicts.

Links and References

Discussion