How we built a free box dieline generator that exports SVG, PDF and DXF
We run a custom packaging company, and every designer who prepares artwork for a box needs the dieline first. A dieline is the flat template of a box: where the board is cut, where it folds, and where the glue goes.
So we built a free generator that draws one to any size in the browser. This post covers how it works, because the interesting parts were not the ones we expected.
The model: flat pieces, shared edges
Every box style is described as a set of flat polygons in inches. The rule that makes everything else simple:
- an edge shared by two pieces is a fold
- an edge that belongs to one piece is a cut
Extra folds (diagonal scores), extra cuts (slots, handle holes), glue areas, safe zones and labels are listed separately.
A reverse tuck end carton and a gable box are then just different lists of polygons built from length, width, depth and board thickness.
Board thickness changes the geometry
A carton in 0.018 in paperboard and a mailer in 1/16 in E-flute cannot share a template. Panels that wrap around other panels have to grow by the board caliper, and tuck flaps need clearance.
The generator takes the board as an input (SBS paperboard, E-flute or B-flute) and every style applies it in its own construction rules.
One display list, three writers
The geometry does not draw anything. It produces a display list: filled paths, stroked paths and text, in page units of PostScript points (72 per inch). Three small writers turn that list into SVG, PDF and DXF.
Because the page unit is the point, the SVG (sized in inches) and the PDF both print at true size at 100% scale. The PDF carries a 1 inch scale bar so you can check with a ruler.
Bleed without polygon offsetting
Offsetting an arbitrary outline by 0.125 in is a classic source of bugs. We avoided it: each piece is stroked at twice the bleed width with round joins, then filled white. What is left outside the outline is exactly the bleed band.
Two implementations, one parity test
The same geometry exists twice: in Python, for the template files we pre-generate, and in JavaScript, for the live tool in the browser. To stop them drifting apart, a test builds the display list in both for a set of styles, sizes, boards and units, and fails if any number differs by more than 0.02 pt or any label differs.
The same test checks construction rules per style: panel sums, the glue mapping of a crash-lock bottom in the flat and erected states, gable slant lengths, the arc length of a pillow box, and tray and lid fit.
What we would tell anyone building one
- Model the box, not the drawing. Cuts and folds fall out of the pieces.
- Treat board thickness as a first-class input.
- Keep output formats as dumb writers over one display list.
- If the logic lives in two languages, make a test compare them number by number.
The generator is free to use and covers 14 styles, including tuck end, auto-lock bottom, mailer, pillow, sleeve, two-piece, gable, pizza, hexagon and cake boxes: Vorex dieline generator. Happy to answer questions about any of the box styles in the comments.
Comments
No comments yet. Start the discussion.