DXF to PNG
Nothing you choose here leaves your browser, and nothing is downloaded to make it work. A DXF is a text file of numbered pairs — the geometry is written as coordinates, not as a picture — so reading one is arithmetic rather than decoding.
For putting a drawing in a document.
The drawing is worked out as vectors first and then drawn once, at the size you choose, so the result is as sharp as the size allows rather than a small picture stretched. The units are gone though. A DXF is drawn in millimetres or inches; a PNG is drawn in pixels, and nothing in the file records what one pixel used to be. The proportions are exact; the scale is not recoverable.
A DXF is not a DWG
They come out of the same programs and people use the names interchangeably, and they are not the same file. DWG is AutoCAD's own binary format — undocumented, versioned, and not readable without a library that has been reverse engineered at considerable effort. DXF is the one Autodesk published so that other software could read it, and it is plain text. That is the entire reason this page can exist without downloading anything, and the reason there is no DWG page here: opening one would mean fetching a megabyte of decoder, which this site does not do.
If you have a .dwg, the program that made it will export a .dxf: in AutoCAD it is Save As, and in most others it is under Export.
The header says how big the drawing is, and it is usually lying
Every DXF carries $EXTMIN and
$EXTMAX in its header, which look exactly like what a
converter needs to set up its page. Measured, on a drawing
holding a single line from (0, 0) to (1000, 700):
| $EXTMIN | 1e+20, 1e+20, 1e+20 |
|---|---|
| $EXTMAX | -1e+20, -1e+20, -1e+20 |
That is the never-computed sentinel. AutoCAD fills those in when you zoom to extents, not when you save, and a file written by a library is very likely never to have had it done. A converter that believes them produces a perfectly valid picture of nothing, with no error anywhere. This page ignores both and measures the entities.
Older files draw their outlines a different way
A modern DXF stores an outline as one
LWPOLYLINE entity. That entity did not exist before
the R2000 release — ezdxf, asked to write one into an R12
file, refuses outright with “LWPOLYLINE requires DXF
R2000”. R12 files, which is what a great deal of older CAD and
most laser cutters and plasma tables still write, use a
POLYLINE followed by a run of separate VERTEX
entities and a SEQEND to finish.
A converter that only knows the modern one draws every
line and circle in such a file and silently draws none of the outlines.
It does not fail. It gives you most of a drawing. Both forms are
read here, and so is the trap inside the old one: the
POLYLINE entity carries a point of its own, at (0, 0),
which is not a vertex — treat it as one and every outline gains a
spur running to the origin.
A corner that is really a curve
A polyline vertex can carry a bulge: one number that turns the segment after it into an arc. It is the tangent of a quarter of the arc's included angle, positive for counter-clockwise, and it is simply absent when it is zero — so a reader that counts them off in order rather than attaching each one to the vertex it follows puts the curves in the wrong places.
Ignore bulges altogether and every rounded corner becomes a square one. The drawing still opens, still looks like a drawing, and is the wrong shape — in a file somebody may be about to cut metal with. They are converted to real arcs here.
One unit is not one pixel
A DXF is drawn in real units and does not always say
which. The header's $INSUNITS names them — 4 is
millimetres, 1 is inches, 6 is metres — and
0 means “unitless”, which a great many real files
say. The tag is missing altogether in older releases.
A raster picture cannot carry it either way. The proportions here are exact and the scale is not recoverable from the result: nothing in a PNG records what one pixel used to be. If the size matters, DXF to SVG keeps it.
What it will not draw
Splines, hatches, dimensions and leaders. Those are counted and named on screen rather than left out quietly, because a drawing that has lost its dimensions without saying so is worse than one that tells you. Approximating them would mean putting lines in your file that were never in the drawing, which is a worse answer than a short list of what is missing.
- It reads model space. Paper-space layouts, title blocks and viewports are not drawn.
- It reads X and Y. A DXF can hold 3D geometry, and what you get is a plan view of it — which is right for a flat drawing and wrong for a model.
- It draws in one colour. Colour in a DXF is an index into a table the file does not always carry. DXF to CSV keeps the layer names.
- Block references are expanded and placed, with their scale, rotation and base point applied. Nesting deeper than eight levels is counted rather than followed.