pdf2gerb: Convert PDF to Gerber and NC Drill formats
I prefer to design circuit board layouts in Adobe Illustrator — it's a familiar tool and I get results quickly. PCB manufacturers expect designs in Gerber + NC Drill format, however, and the best Illustrator can do is export to PDF.
Converting PDF to Gerber
The PDF and Gerber file formats are very similar. PDF commands move a pen from point to point, drawing lines and changing stroke weights. Similarly, Gerber commands move a photoplotter head around a circuit board, exposing lines and changing apertures. The concept is the same but the grammar is different.
For example, the PDF command "350 450 m" moves the pen to coordinate (350, 450). The Gerber equivalent is "X350Y450D02". ".5 w" changes the PDF stroke weight; "G54D10" changes the Gerber aperture.
pdf2gerb reads a PDF file line-by-line, converting each command to its Gerber equivalent.
Converting PDF to NC Drill
An NC (aka Excellon) Drill file specifies drill coordinates and diameters for the circuit board. In my PDF file, I represent each drill hole as a solid white circle placed atop the corresponding solder pad (a solid black circles).
pdf2gerb looks for filled white circles in a PDF and outputs their coordinates and diameters as NC Drill commands.
pdf2gerb creates a Gerber and NC Drill file for each layer in the PDF file. Simply draw the board in Illustrator using multiple layers as though you were looking top-down through the board with x-ray vision.
Here is a double-sided board I drew in Illustrator and converted with pdf2gerb:
...and here's the board I received from BatchPCB:
Here's how I prepared the board —
- Did a rough layout of the board on graph paper
- Redrew the layout in Illustrator:
- Created several layers: Top Copper, Bottom Copper, Top Silkscreen, Soldermask, and Drill.
- Drew holes in the Drill layer as a solid black circle (for the pad) with a solid white circle on top (for the drill location and diameter)
- Used the pen tool on the Top and Bottom layers to add traces between pads
- Drew solid black circles in the Soldermask layer to cover each pad
- Drew a rectangle around the board in the Silkscreen layer
- Copied the Drill layer into top and bottom layers (may not have been necessary)
- Exported the layout in PDF format:
- Selected PDF 1.3 format
- Unchecked "Preserve Illustrator Editing Capabilities"
- Unchecked "Embed Page Thumbnails"
- On the Compression page, unchecked "Compress Text and Line Art"
- Ran 'pdf2gerb.pl /path/to/circuit.pdf'
- Renamed 'Top Copper.drd' to 'Drill.drd'
- Made a .zip file of Top Copper.grb, Bottom Copper.grb, Top Silkscreen.grb, Soldermask.grb, and Drill.drd
- Submitted the .zip file to BatchPCB
Download the script here. Right-click on the download link and save it to your computer. Open a Terminal window, navigate to the file you downloaded, and type chmod 755 pdf2gerb.pl to make it executable.
To use pdf2gerb, type ./pdf2gerb.pl /path/to/circuit.pdf. Gerber and NC Drill files will be output to the same location as the PDF file.
Support, licensing, and caveats
If you have comments, suggestions, or issues — or if pdf2gerb helped you build something cool — send me an email at email@example.com.