EditorJS to DOCX/PDF

Exporting Reports from the HTML WYSIWYG Tool EditorJS Convert the JSON output of Editor.js to a PDF with Carbone

Download Template

Download data sample

  • Template type document docx simple
  • Carbone min. v4.0.0+
  • Features array filter
  • Target editorjs conversion

Objectives

Convert the JSON output of Editor.js to a PDF using Carbone, with the following features:

  • Header, title, subtitle
  • Paragraph, Html
  • List, table
  • Annex, image

Solution

The best approach is to use a template with a main structure based on a table, where each style is predefined and conditionally displayed as needed.

Here’s how to construct a template to achieve this with Carbone:

  1. Create a global table

    • Insert a table with a single column that spans the full width of the page.
    • Configure it with no borders for better integration.
  2. Create a row per style

    • For each style (e.g., paragraph, header, list, table...), define a row to specify the format settings
    • Set parameters such as font, indentation and spacing within the Carbone tag (e.g., {d.blocks[i].data.text})
  3. Test the type to keep the line if it matches

    • In each row, use ifEQ formatter to test the data and control the display, such as: {d.blocks[i].type:ifEQ('paragraph'):keep(row)}

And there you go!

Trusted by 600+ paid customers in 40+ countries

Finance
Healthcare
Public
Retail
Industries
Energy
Software
Telecom
1dior.png
22thales.png
23younited.png
2danfoss.png
3cma-cgm.png
3illumina.svg
4KparK.png
6scalingo.png
7defense.png
8bmw.png
8telus.png
bestseller.png
flagship_bioscience.png
insly.png
ninox.png
sodexo.png