gerber to svg
Render individual Gerber / NC drill files as SVGs
Part of the tracespace collection of PCB visualization tools.
npm install --save gerber-to-svg# oryarn add gerber-to-svg
cd tracespace/packages/gerber-to-svgnpm run example
Arduino Uno design files used here under the terms of the Creative Commons Attribution Share-Alike license.
var gerberToSvg =var converter =
See the API documentation for full details.
If you would like to use
gerber-to-svg from the command line, check out
Since Gerber is a vector image format, this library takes in a Gerber file and spits it out in a different vector format: SVG. This converter uses RS-274X and strives to be true to the latest format specification.
Everywhere that is "dark" or "exposed" in the Gerber (think a copper trace or a line on the silkscreen) will be
currentColor in the SVG. You can set this with the
color CSS property or the
color attribute in the SVG node itself.
Everywhere that is "clear" (anywhere that was never drawn on or was drawn on but cleared later) will be transparent. This is accomplished though judicious use of SVG masks and groups.
The bounding box is carefully calculated as the file is being converted, so the
height of the resulting SVG should be nearly (if not exactly) the real world size of the Gerber image. The SVG's
viewBox is in 1000x Gerber units, so its
min-y values can be used to align SVGs generated from different board layers.
Excellon / NC drill files do not have a completely clearly defined spec, so drill file parsing is lenient in its attempt to generate an image. It should auto-detect when a drill file has been entered. You may need to override parsing settings (see API.md) to get drill files to render properly if they do not adhere to certain assumptions. The library must make these assumptions because Excellon does not define commands for certain formatting decisions.