Skip to content

Convert a DXF vector graphics file to HTML 5 <canvas> and/or <svg> drawing primitives

Notifications You must be signed in to change notification settings

skvamme/HTML-vector-graphics

Repository files navigation

This Erlang Program converts a DXF (binary or ASCII) to an HTML file. View it in an HTML5-ready browser (Safari, Chromium etc).

The DXF file can be created in QCAD (free) http://www.ribbonsoft.com/en/ , AUTOCAD and other CAD systems. Note that a closed pline will be filled in the HTML file. Entities with higher thickness will be on top in the HTML file.

1. Mirror your drawing in the CAD-app down over the X-axis (Y=0)
2. Move the drawing up to its previous position (up above the X-axis)
3. Save as DXF
4. Undo Move and Miror

Make sure you have compiled the 3 erl-files, the Erlang command is erlc *.erl

In a terminal, type ./dxf2js.sh myfile 0
to create a file myfile.html with a canvas representation of the drawing at layer 0.

In a terminal, type ./dxf2js.sh myfile svg
to create a file myfile.html with a svg representation of the drawing at layer svg.

If you are on a Windows system you have to create a bat-file or run dxf2js module from the erlang console.

If you are using QCAD, set the paper size in Drawing Preferences.
 

The parameters to dxf2js.sh is a dxffilename without extension, and a layername

If the layer name is svg the output format will be svg, all other layers will be in canvas format. This makes it easy to create a combined svg/canvas graphics.
 
You need to download and install Erlang http://www.erlang.org to run this program. After installation, run erlc *.erl in HTML-vector-graphics directory.
 
 

About

Convert a DXF vector graphics file to HTML 5 <canvas> and/or <svg> drawing primitives

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published