Visual document designer

A React editor for document templates: paper-sized canvas, toolbox, inspector, layers, sample data, a JSON view and built-in View, Print and Submit actions.

The DocStudio designer with a laboratory report open and its results table selected
The DocStudio designer with a laboratory report open and its results table selected

The designer is the Designer component from docstudio/designer. It edits the same JSON template that you can write by hand, and it renders its canvas with the same renderer that produces your output. It runs in the browser and needs no server.

Visual template editing

You build a template on a paper-sized canvas. Select an element to edit it, drag components from the toolbox, reorder them in the layers panel, and undo or redo any change. The page on the canvas has the true size of the paper you chose, with rulers in millimetres.

The component toolbox

The toolbox has 14 components in three groups:

  • Content: Barcode, Divider, Image, Pg number, QR code, Shape, Text
  • Layout: Fixed region, Grid, Row, Section, Stack
  • Data: Repeater, Table

You can insert a component by clicking it, by dragging it onto the canvas, or by using the explicit insert commands. Details are in the toolbox article.

The toolbox with its Content, Layout and Data groups

Layout configuration

Selecting nothing shows the page settings: paper size, orientation, margins, direction and the missing-data policy. Header, body and footer regions are listed in the layers panel, and the insert target follows the region you choose. Flow layout is the default. Absolute positioning is available inside a fixed region, with snapping guides while you move and resize.

Inspector and properties

The inspector adapts to the selected component. Its sections are accordions: Data, Content, Position and size, Typography, Appearance, Border, Conditions and Advanced. The first one is open and the others are closed, and several can be open at once. You can multi-select elements to change shared settings and align them.

The inspector for a selected table

Data editing

The Data tab holds the sample data that drives the canvas. A data path field offers the paths found in that data, and a preview shows the value, its type and the binding state for the current expression. You can wrap a value in a function, apply a formatter, or switch to the raw JSON of an expression.

The Data tab with sample JSON for the laboratory report

JSON view

The JSON tab shows the template as JSON and applies edits you make there. The Problems tab lists every validation diagnostic with the element it belongs to.

The JSON tab showing the template source

Preview, Print and Submit

The toolbar can show view modes for Screen, Print and PDF. When you pass onSubmit, onView, onPrint or actions, it also shows an action group on the right:

  • View opens a modal with the rendered document only.
  • Print opens the browser print dialog for the document only. It is never sent to a server.
  • Submit calls your onSubmit({ template, data }) and shows Saved when it resolves.

The View action showing the rendered laboratory report in a modal

Limits

  • The designer does not save anything by itself. Your application stores the template.
  • On-canvas text editing is not available. Text is edited in the inspector.
  • It is tested in Chromium. Firefox and WebKit are partially tested.
  • The canvas shows one continuous page. Use the Print view or a PDF to see page breaks.

Start with designer setup, and see the full user guide.

Related documentation