Tuesday, 15 November 2016

PDF to Gerber Converter

If you want to make your own permanent electronic circuits and don't want to use either strip- or protoboards, you really have no other option than to etch your own PCB. Or, rather, you had, because nowadays you can find PCB manufacturing services on the internet that make small-run high quality PCBs for little money. Just search for PCB prototyping service and you'll get any number of offers.

Usually, you simply upload your design and specify a few options (board thickness, number of PCBs, etc), and within a week or two you get your very own professionally looking PCBs. Of course, your design needs to be presented in a machine readable file format. In general, one of several popular options can be chosen when you upload.

Sometimes, however, a PCB design that someone offers to the public for DIY purposes is available only in graphical form, for example, because the designer self-etches his PCBs and therefore doesn't need to make files suitable for uploading to a PCB service.

Because I don't etch, I found myself several times in this situation, where a PCB design that was kindly offered by some friendly dude in the DIY community proved to be inaccessible to me. If only I had a program that could convert a PCB design given as a PDF file to a file format suitable for manufacturing.... But then, why not write one myself?

A PDF to Gerber Converter

I knew from writing a PDF reader in an earlier life, that PDF is basically a graphics file format. It consists of a sequence of graphics commands such as "draw line from here to there using color X" that together represent the page that you see on the screen or printed on paper. If instead of painting these lines on the screen I converted them to commands in a command language like Gerber -- one of the common file formats for manufacturing PCBs -- and then write these commands to a file, I could upload this file and have the PCB made, without me having to get my hands dirty! YES!!

After several days (and nights) of hacking, I managed to complete a simple quick'n'dirty PDF-to-Gerber-converter that can read and process most PCB designs given in PDF format. In addition to the PCB traces, it can identify solder pads and holes, and produce appropriate solder mask and drill files. You only need to manually specify the outline of the PCB (to also create an outline file) -- and perhaps additional pads or traces that need to be free of solder mask (for edge connectors etc). It even converts text on the solder side to a vector format. But it needs to be a PDF with line graphics. It can't, and likely never will, convert bitmaps.

At this stage, it can handle only single-sided boards. It doesn't convert silk screen lettering, either. And it crashes often. But still, I managed to make Gerber files for the boards of my MiniMoog clone based on PDFs published by Crazy Patroche on his own MiniMoog report [French].

Screen shot of Mini Moog VCO board with output screen open.
Blue/orange/green blobs are solder pads.
I'm currently done converting PDFs, which is why the software rots quietly on my hard disk. I'd like to make a Web-based online converter some time in the future, but there's more pressing stuff on my todo list right now.

Clarification regarding the image above: If a board outline is specified, only those traces and pads within the outline are output to the Gerber file. The circles and pads above and below the circuit in the image are of course ignored.