aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am27
-rw-r--r--src/gerber-output-dev.cc285
-rw-r--r--src/gerber-output-dev.h287
-rw-r--r--src/main.cc57
4 files changed, 656 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..1ecbcfd
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,27 @@
+## Process this file with automake to produce Makefile.in
+
+## Created by Anjuta
+
+AM_CPPFLAGS = \
+ -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
+ -DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
+ "$(POPPLER_CFLAGS)" \
+ -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\"
+
+AM_CFLAGS =\
+ -Wall\
+ -g
+
+bin_PROGRAMS = pdf2gerber
+
+pdf2gerber_SOURCES = \
+ main.cc \
+ gerber-output-dev.cc \
+ gerber-output-dev.h
+
+pdf2gerber_LDFLAGS =
+
+pdf2gerber_LDADD = \
+ $(POPPLER_LIBS)
+
+
diff --git a/src/gerber-output-dev.cc b/src/gerber-output-dev.cc
new file mode 100644
index 0000000..f4b4aab
--- /dev/null
+++ b/src/gerber-output-dev.cc
@@ -0,0 +1,285 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
+/*
+ * gerber-output-dev.cc
+ * Copyright (C) 2018 David Barksdale <amatus@amat.us>
+ *
+ * pdf2gerber is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * pdf2gerber is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <cmath>
+#include <iostream>
+#include <GfxState.h>
+#include "gerber-output-dev.h"
+
+static double midpoint(double a, double b, double c, double d)
+{
+ return (a + 3 * (b + c) + d) / 8;
+}
+
+static void center(double x0, double y0,
+ double x1, double y1,
+ double x2, double y2,
+ double *x, double *y)
+{
+ double idet = 1 / ((x0 - x1) * (y1 - y2) - (x1 - x2) * (y0 - y1));
+ double offset = x1 * x1 + y1 * y1;
+ double m01 = (x0 * x0 + y0 * y0 - offset) / 2;
+ double m12 = (offset - x2 * x2 - y2 * y2) / 2;
+
+ *x = (m01 * (y1 - y2) - m12 * (y0 - y1)) * idet;
+ *y = (m12 * (x0 - x1) - m01 * (x1 - x2)) * idet;
+}
+
+static bool clockwise(double x0, double y0,
+ double x1, double y1,
+ double x2, double y2)
+{
+ return (x1 - x0) * (y2 - y0) < (x2 - x0) * (y1 - y0);
+}
+
+// Constructor.
+GerberOutputDev::GerberOutputDev()
+{
+ // Set format to 6.6
+ std::cout << "%FSLAX66Y66*%" << std::endl
+ // Set units to mm
+ << "%MOMM*%" << std::endl
+ // Set multi-quadrant, why would you ever not want this?
+ << "G75*" << std::endl;
+}
+
+// Does this device use upside-down coordinates?
+// (Upside-down means (0,0) is the top left corner of the page.)
+GBool GerberOutputDev::upsideDown()
+{
+ return gFalse;
+}
+
+// Does this device use drawChar() or drawString()?
+GBool GerberOutputDev::useDrawChar()
+{
+ return gTrue;
+}
+
+// Does this device use beginType3Char/endType3Char? Otherwise,
+// text in Type 3 fonts will be drawn with drawChar/drawString.
+GBool GerberOutputDev::interpretType3Chars()
+{
+ return gFalse;
+}
+
+// Start a page.
+void GerberOutputDev::startPage(int pageNum, GfxState *state, XRef *xref)
+{
+ std::cout << "G04 startPage "
+ << pageNum << "*" << std::endl;
+}
+
+// End a page.
+void GerberOutputDev::endPage()
+{
+ std::cout << "G04 endPage*" << std::endl;
+ std::cout << "M02*" << std::endl;
+}
+
+// Dump page contents to display.
+void GerberOutputDev::dump()
+{
+ //std::cerr << "dump" << std::endl;
+}
+
+//----- path painting
+void GerberOutputDev::stroke(GfxState *state)
+{
+ GfxPath *path = state->getPath();
+ double width = state->getTransformedLineWidth();
+ GfxGray gray;
+
+ state->getStrokeGray(&gray);
+ std::cout << "G04 stroke width " << width
+ << " gray " << colToDbl(gray) << "*" << std::endl;
+ // McCAD seems to always generate vertical or horizontal strokes.
+ // Since stoking an aperature will add stuff to the ends of the stroke
+ // we're just going to make a region.
+ if (1 != path->getNumSubpaths()) {
+ std::cerr << "Stroke with more than 1 sub-path" << std::endl;
+ return;
+ }
+ GfxSubpath *subpath = path->getSubpath(0);
+
+ if (0 != state->getLineCap()) {
+ std::cerr << "Stoke with non-but line cap" << std::endl;
+ return;
+ }
+ if (colToDbl(gray) < 0.5) {
+ // Set polarity to dark
+ std::cout << "%LPD*%" << std::endl;
+ } else {
+ // Set polarity to clear
+ std::cout << "%LPC*%" << std::endl;
+ }
+ std::cout << "G36*" << std::endl;
+ if (2 == subpath->getNumPoints()) {
+ double x0, y0, x1, y1;
+
+ state->transform(subpath->getX(0), subpath->getY(0), &x0, &y0);
+ state->transform(subpath->getX(1), subpath->getY(1), &x1, &y1);
+ double dx = x1 - x0;
+ double dy = y1 - y0;
+ double l = sqrt(dx * dx + dy * dy);
+ // half-width perpendicular vector
+ double hwx = dy / l * width / 2;
+ double hwy = -dx / l * width / 2;
+
+ std::cout << "X" << coord(x0 + hwx) << "Y" << coord(y0 + hwy)
+ << "D02*" << std::endl;
+ std::cout << "G01*" << std::endl;
+ std::cout << "X" << coord(x0 - hwx) << "Y" << coord(y0 - hwy)
+ << "D01*" << std::endl;
+ std::cout << "X" << coord(x1 - hwx) << "Y" << coord(y1 - hwy)
+ << "D01*" << std::endl;
+ std::cout << "X" << coord(x1 + hwx) << "Y" << coord(y1 + hwy)
+ << "D01*" << std::endl;
+
+ } else if (13 == subpath->getNumPoints()) {
+ // I lied, sometimes there are circles
+ double x0, y0, x1, y1;
+
+ state->transform(subpath->getX(0), subpath->getY(0), &x0, &y0);
+ state->transform(subpath->getX(6), subpath->getY(6), &x1, &y1);
+ double cx = (x0 + x1) / 2;
+ double cy = (y0 + y1) / 2;
+ double hw = width / 2;
+
+ std::cout << "G04 x0 " << x0 << " y0 " << y0
+ << " x1 " << x1 << " y1 " << y1 << "*" << std::endl;
+ // Make outer circle
+ std::cout << "X" << coord(x0 - hw) << "Y" << coord(y0)
+ << "D02*" << std::endl;
+ std::cout << "G02*" << std::endl;
+ std::cout << "X" << coord(x1 + hw) << "Y" << coord(y1)
+ << "I" << coord(cx - (x0 - hw)) << "J" << coord(cy - y0)
+ << "D01*" << std::endl;
+ std::cout << "X" << coord(x0 - hw) << "Y" << coord(y0)
+ << "I" << coord(cx - (x1 + hw)) << "J" << coord(cy - y1)
+ << "D01*" << std::endl;
+ // Make inner circle
+ std::cout << "G01*" << std::endl;
+ std::cout << "X" << coord(x0 + hw) << "Y" << coord(y0)
+ << "D01*" << std::endl;
+ std::cout << "G03*" << std::endl;
+ std::cout << "X" << coord(x1 - hw) << "Y" << coord(y1)
+ << "I" << coord(cx - (x0 + hw)) << "J" << coord(cy - y0)
+ << "D01*" << std::endl;
+ std::cout << "X" << coord(x0 + hw) << "Y" << coord(y0)
+ << "I" << coord(cx - (x1 - hw)) << "J" << coord(cy - y1)
+ << "D01*" << std::endl;
+ } else {
+ std::cerr << "Stroke with points I can't handle" << std::endl;
+ }
+ std::cout << "G37*" << std::endl;
+}
+
+void GerberOutputDev::fill(GfxState *state)
+{
+ // McCAD seems to generate fills for any shape that's not a rectangle,
+ // rectangles are made with either vertical or horizontal strokes.
+ GfxPath *path = state->getPath();
+ int nsubpaths = path->getNumSubpaths();
+ GfxGray gray;
+
+ state->getFillGray(&gray);
+ std::cout << "G04 fill " << nsubpaths << " subpath(s) gray "
+ << colToDbl(gray) << "*" << std::endl;
+
+ if (colToDbl(gray) < 0.5) {
+ // Set polarity to dark
+ std::cout << "%LPD*%" << std::endl;
+ } else {
+ // Set polarity to clear
+ std::cout << "%LPC*%" << std::endl;
+ }
+
+ // Use a filled region
+ std::cout << "G36*" << std::endl;
+ for (int i = 0; i < nsubpaths; ++i) {
+ GfxSubpath *subpath = path->getSubpath(i);
+ int npoints = subpath->getNumPoints();
+ int j = 1;
+ double x, y;
+
+ state->transform(subpath->getX(0), subpath->getY(0), &x, &y);
+ std::cout << "X" << coord(x) << "Y" << coord(y) << "D02*" << std::endl;
+
+ while (j < npoints) {
+ if (subpath->getCurve(j)) {
+ // This is a bezier curve, approximate it with a single arc!
+ double x0, y0, x1, y1, x2, y2;
+
+ state->transform(subpath->getX(j), subpath->getY(j), &x0, &y0);
+ state->transform(subpath->getX(j + 1), subpath->getY(j + 1), &x1, &y1);
+ state->transform(subpath->getX(j + 2), subpath->getY(j + 2), &x2, &y2);
+ j += 3;
+
+ double mx = midpoint(x, x0, x1, x2);
+ double my = midpoint(y, y0, y1, y2);
+ double cx, cy;
+
+ center(x, y, mx, my, x2, y2, &cx, &cy);
+ if (clockwise(x0, y0, mx, my, x2, y2)) {
+ // Set clockwise circular interpolation
+ std::cout << "G02*" << std::endl;
+ } else {
+ // Set counterclockwise circular interpolation
+ std::cout << "G03*" << std::endl;
+ }
+ // Arc to x,y with center offset i,j
+ std::cout << "X" << coord(x2) << "Y" << coord(y2)
+ << "I" << coord(cx - x) << "J" << coord(cy - y)
+ << "D01*" << std::endl;
+ x = x2;
+ y = y2;
+ } else {
+ state->transform(subpath->getX(j), subpath->getY(j), &x, &y);
+ // Set linear interpolation
+ std::cout << "G01*" << std::endl
+ // Line to x,y
+ << "X" << coord(x) << "Y" << coord(y) << "D01*" << std::endl;
+ ++j;
+ }
+ }
+ }
+ std::cout << "G37*" << std::endl;
+}
+
+//----- text drawing
+void GerberOutputDev::drawChar(GfxState *state, double x, double y,
+ double dx, double dy,
+ double originX, double originY,
+ CharCode code, int nBytes, Unicode *u, int uLen)
+{
+ std::cout << "G04 drawChar("
+ << x << ", "
+ << y << ", "
+ << dx << ", "
+ << dy << ", "
+ << originX << ", "
+ << originY << ", ...)*" << std::endl;
+}
+
+int GerberOutputDev::coord(double decimal)
+{
+ return round(decimal * 1000000);
+}
+
diff --git a/src/gerber-output-dev.h b/src/gerber-output-dev.h
new file mode 100644
index 0000000..f3c6963
--- /dev/null
+++ b/src/gerber-output-dev.h
@@ -0,0 +1,287 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
+/*
+ * gerber-output-dev.h
+ * Copyright (C) 2018 David Barksdale <amatus@amat.us>
+ *
+ * pdf2gerber is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * pdf2gerber is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _GERBER_OUTPUT_DEV_H_
+#define _GERBER_OUTPUT_DEV_H_
+
+#include <OutputDev.h>
+
+class GerberOutputDev: public OutputDev
+{
+public:
+ // Constructor.
+ GerberOutputDev();
+
+ //----- get info about output device
+
+ // Does this device use upside-down coordinates?
+ // (Upside-down means (0,0) is the top left corner of the page.)
+ GBool upsideDown();
+
+ // Does this device use drawChar() or drawString()?
+ GBool useDrawChar();
+
+ // Does this device use tilingPatternFill()? If this returns false,
+ // tiling pattern fills will be reduced to a series of other drawing
+ // operations.
+ virtual GBool useTilingPatternFill() { return gFalse; }
+
+ // Does this device support specific shading types?
+ // see gouraudTriangleShadedFill() and patchMeshShadedFill()
+ virtual GBool useShadedFills(int type) { return gFalse; }
+
+ // Does this device use FillColorStop()?
+ virtual GBool useFillColorStop() { return gFalse; }
+
+ // Does this device use drawForm()? If this returns false,
+ // form-type XObjects will be interpreted (i.e., unrolled).
+ virtual GBool useDrawForm() { return gFalse; }
+
+ // Does this device use beginType3Char/endType3Char? Otherwise,
+ // text in Type 3 fonts will be drawn with drawChar/drawString.
+ GBool interpretType3Chars();
+
+ // Does this device need non-text content?
+ virtual GBool needNonText() { return gTrue; }
+
+ // Does this device require incCharCount to be called for text on
+ // non-shown layers?
+ virtual GBool needCharCount() { return gFalse; }
+
+ // Does this device need to clip pages to the crop box even when the
+ // box is the crop box?
+ virtual GBool needClipToCropBox() { return gFalse; }
+
+ //----- initialization and control
+
+ // Set default transform matrix.
+// virtual void setDefaultCTM(double *ctm);
+
+ // Check to see if a page slice should be displayed. If this
+ // returns false, the page display is aborted. Typically, an
+ // OutputDev will use some alternate means to display the page
+ // before returning false.
+ virtual GBool checkPageSlice(Page *page, double hDPI, double vDPI,
+ int rotate, GBool useMediaBox, GBool crop,
+ int sliceX, int sliceY, int sliceW, int sliceH,
+ GBool printing,
+ GBool (* abortCheckCbk)(void *data) = NULL,
+ void * abortCheckCbkData = NULL,
+ GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data) = NULL,
+ void *annotDisplayDecideCbkData = NULL)
+ { return gTrue; }
+
+ // Start a page.
+ void startPage(int pageNum, GfxState *state, XRef *xref);
+
+ // End a page.
+ void endPage();
+
+ // Dump page contents to display.
+ void dump();
+
+ //----- coordinate conversion
+
+ // Convert between device and user coordinates.
+// virtual void cvtDevToUser(double dx, double dy, double *ux, double *uy);
+// virtual void cvtUserToDev(double ux, double uy, int *dx, int *dy);
+
+ //----- save/restore graphics state
+ virtual void saveState(GfxState * /*state*/) {}
+ virtual void restoreState(GfxState * /*state*/) {}
+
+ //----- update graphics state
+// virtual void updateAll(GfxState *state);
+ virtual void updateCTM(GfxState * /*state*/, double /*m11*/, double /*m12*/,
+ double /*m21*/, double /*m22*/, double /*m31*/, double /*m32*/) {}
+ virtual void updateLineDash(GfxState * /*state*/) {}
+ virtual void updateFlatness(GfxState * /*state*/) {}
+ virtual void updateLineJoin(GfxState * /*state*/) {}
+ virtual void updateLineCap(GfxState * /*state*/) {}
+ virtual void updateMiterLimit(GfxState * /*state*/) {}
+ virtual void updateLineWidth(GfxState * /*state*/) {}
+ virtual void updateStrokeAdjust(GfxState * /*state*/) {}
+ virtual void updateAlphaIsShape(GfxState * /*state*/) {}
+ virtual void updateTextKnockout(GfxState * /*state*/) {}
+ virtual void updateFillColorSpace(GfxState * /*state*/) {}
+ virtual void updateStrokeColorSpace(GfxState * /*state*/) {}
+ virtual void updateFillColor(GfxState * /*state*/) {}
+ virtual void updateStrokeColor(GfxState * /*state*/) {}
+ virtual void updateBlendMode(GfxState * /*state*/) {}
+ virtual void updateFillOpacity(GfxState * /*state*/) {}
+ virtual void updateStrokeOpacity(GfxState * /*state*/) {}
+ virtual void updatePatternOpacity(GfxState * /*state*/) {}
+ virtual void clearPatternOpacity(GfxState * /*state*/) {}
+ virtual void updateFillOverprint(GfxState * /*state*/) {}
+ virtual void updateStrokeOverprint(GfxState * /*state*/) {}
+ virtual void updateOverprintMode(GfxState * /*state*/) {}
+ virtual void updateTransfer(GfxState * /*state*/) {}
+ virtual void updateFillColorStop(GfxState * /*state*/, double /*offset*/) {}
+
+ //----- update text state
+ virtual void updateFont(GfxState * /*state*/) {}
+ virtual void updateTextMat(GfxState * /*state*/) {}
+ virtual void updateCharSpace(GfxState * /*state*/) {}
+ virtual void updateRender(GfxState * /*state*/) {}
+ virtual void updateRise(GfxState * /*state*/) {}
+ virtual void updateWordSpace(GfxState * /*state*/) {}
+ virtual void updateHorizScaling(GfxState * /*state*/) {}
+ virtual void updateTextPos(GfxState * /*state*/) {}
+ virtual void updateTextShift(GfxState * /*state*/, double /*shift*/) {}
+ virtual void saveTextPos(GfxState * /*state*/) {}
+ virtual void restoreTextPos(GfxState * /*state*/) {}
+
+ //----- path painting
+ void stroke(GfxState * /*state*/);
+ void fill(GfxState * /*state*/);
+ //void eoFill(GfxState * /*state*/);
+ virtual GBool tilingPatternFill(GfxState * /*state*/, Gfx * /*gfx*/, Catalog * /*cat*/, Object * /*str*/,
+ double * /*pmat*/, int /*paintType*/, int /*tilingType*/, Dict * /*resDict*/,
+ double * /*mat*/, double * /*bbox*/,
+ int /*x0*/, int /*y0*/, int /*x1*/, int /*y1*/,
+ double /*xStep*/, double /*yStep*/)
+ { return gFalse; }
+ virtual GBool functionShadedFill(GfxState * /*state*/,
+ GfxFunctionShading * /*shading*/)
+ { return gFalse; }
+ virtual GBool axialShadedFill(GfxState * /*state*/, GfxAxialShading * /*shading*/, double /*tMin*/, double /*tMax*/)
+ { return gFalse; }
+ virtual GBool axialShadedSupportExtend(GfxState * /*state*/, GfxAxialShading * /*shading*/)
+ { return gFalse; }
+ virtual GBool radialShadedFill(GfxState * /*state*/, GfxRadialShading * /*shading*/, double /*sMin*/, double /*sMax*/)
+ { return gFalse; }
+ virtual GBool radialShadedSupportExtend(GfxState * /*state*/, GfxRadialShading * /*shading*/)
+ { return gFalse; }
+ virtual GBool gouraudTriangleShadedFill(GfxState *state, GfxGouraudTriangleShading *shading)
+ { return gFalse; }
+ virtual GBool patchMeshShadedFill(GfxState *state, GfxPatchMeshShading *shading)
+ { return gFalse; }
+
+ //----- path clipping
+ virtual void clip(GfxState * /*state*/) {}
+ virtual void eoClip(GfxState * /*state*/) {}
+ virtual void clipToStrokePath(GfxState * /*state*/) {}
+
+ //----- text drawing
+ virtual void beginStringOp(GfxState * /*state*/) {}
+ virtual void endStringOp(GfxState * /*state*/) {}
+ virtual void beginString(GfxState * /*state*/, GooString * /*s*/) {}
+ virtual void endString(GfxState * /*state*/) {}
+ void drawChar(GfxState * /*state*/, double /*x*/, double /*y*/,
+ double /*dx*/, double /*dy*/,
+ double /*originX*/, double /*originY*/,
+ CharCode /*code*/, int /*nBytes*/, Unicode * /*u*/, int /*uLen*/);
+ virtual void drawString(GfxState * /*state*/, GooString * /*s*/) {}
+// virtual GBool beginType3Char(GfxState * /*state*/, double /*x*/, double /*y*/,
+// double /*dx*/, double /*dy*/,
+// CharCode /*code*/, Unicode * /*u*/, int /*uLen*/);
+ virtual void endType3Char(GfxState * /*state*/) {}
+ virtual void beginTextObject(GfxState * /*state*/) {}
+ virtual void endTextObject(GfxState * /*state*/) {}
+ virtual void incCharCount(int /*nChars*/) {}
+ virtual void beginActualText(GfxState * /*state*/, GooString * /*text*/ ) {}
+ virtual void endActualText(GfxState * /*state*/) {}
+
+ //----- image drawing
+// virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
+// int width, int height, GBool invert, GBool interpolate,
+// GBool inlineImg);
+// virtual void setSoftMaskFromImageMask(GfxState *state,
+// Object *ref, Stream *str,
+// int width, int height, GBool invert,
+// GBool inlineImg, double *baseMatrix);
+// virtual void unsetSoftMaskFromImageMask(GfxState *state, double *baseMatrix);
+// virtual void drawImage(GfxState *state, Object *ref, Stream *str,
+// int width, int height, GfxImageColorMap *colorMap,
+// GBool interpolate, int *maskColors, GBool inlineImg);
+// virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
+// int width, int height,
+// GfxImageColorMap *colorMap, GBool interpolate,
+// Stream *maskStr, int maskWidth, int maskHeight,
+// GBool maskInvert, GBool maskInterpolate);
+// virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
+// int width, int height,
+// GfxImageColorMap *colorMap,
+// GBool interpolate,
+// Stream *maskStr,
+// int maskWidth, int maskHeight,
+// GfxImageColorMap *maskColorMap,
+// GBool maskInterpolate);
+
+ //----- grouping operators
+
+// virtual void endMarkedContent(GfxState *state);
+// virtual void beginMarkedContent(char *name, Dict *properties);
+// virtual void markPoint(char *name);
+// virtual void markPoint(char *name, Dict *properties);
+
+
+
+#if OPI_SUPPORT
+ //----- OPI functions
+// virtual void opiBegin(GfxState *state, Dict *opiDict);
+// virtual void opiEnd(GfxState *state, Dict *opiDict);
+#endif
+
+ //----- Type 3 font operators
+ virtual void type3D0(GfxState * /*state*/, double /*wx*/, double /*wy*/) {}
+ virtual void type3D1(GfxState * /*state*/, double /*wx*/, double /*wy*/,
+ double /*llx*/, double /*lly*/, double /*urx*/, double /*ury*/) {}
+
+ //----- form XObjects
+ virtual void drawForm(Ref /*id*/) {}
+
+ //----- PostScript XObjects
+ virtual void psXObject(Stream * /*psStream*/, Stream * /*level1Stream*/) {}
+
+ //----- Profiling
+// virtual void startProfile();
+// virtual GooHash *getProfileHash() {return profileHash; }
+// virtual GooHash *endProfile();
+
+ //----- transparency groups and soft masks
+ virtual GBool checkTransparencyGroup(GfxState * /*state*/, GBool /*knockout*/) { return gTrue; }
+ virtual void beginTransparencyGroup(GfxState * /*state*/, double * /*bbox*/,
+ GfxColorSpace * /*blendingColorSpace*/,
+ GBool /*isolated*/, GBool /*knockout*/,
+ GBool /*forSoftMask*/) {}
+ virtual void endTransparencyGroup(GfxState * /*state*/) {}
+ virtual void paintTransparencyGroup(GfxState * /*state*/, double * /*bbox*/) {}
+ virtual void setSoftMask(GfxState * /*state*/, double * /*bbox*/, GBool /*alpha*/,
+ Function * /*transferFunc*/, GfxColor * /*backdropColor*/) {}
+ virtual void clearSoftMask(GfxState * /*state*/) {}
+
+ //----- links
+ virtual void processLink(AnnotLink * /*link*/) {}
+
+#if 1 //~tmp: turn off anti-aliasing temporarily
+ virtual GBool getVectorAntialias() { return gFalse; }
+ virtual void setVectorAntialias(GBool /*vaa*/) {}
+#endif
+
+#ifdef USE_CMS
+ PopplerCache *getIccColorSpaceCache();
+#endif
+
+private:
+ int coord(double decimal);
+};
+
+#endif // _GERBER_OUTPUT_DEV_H_
+
diff --git a/src/main.cc b/src/main.cc
new file mode 100644
index 0000000..ecb986b
--- /dev/null
+++ b/src/main.cc
@@ -0,0 +1,57 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * main.cc
+ * Copyright (C) 2018 David Barksdale <amatus@amat.us>
+ *
+ * pdf2gerber is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * pdf2gerber is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <iostream>
+#include <GlobalParams.h>
+#include <PDFDocFactory.h>
+#include <PDFDoc.h>
+#include <goo/GooString.h>
+#include "gerber-output-dev.h"
+
+int main()
+{
+ int ret = 0;
+ PDFDocFactory factory;
+ PDFDoc *doc = factory.createPDFDoc(GooString("fd://0"));
+ GerberOutputDev *gerber_out;
+
+ if (!doc->isOk()) {
+ std::cerr << "Unable to read document (" << doc->getErrorCode() << ")"
+ << std::endl;
+ ret = -1;
+ goto free_doc;
+ }
+ std::cerr << "Read document with " << doc->getNumPages() << " page(s)"
+ << std::endl;
+ globalParams = new GlobalParams();
+ gerber_out = new GerberOutputDev();
+ doc->displayPage(gerber_out, // out
+ 1, // page
+ 72.0, // hDPI
+ 72.0, // vDPI
+ 0, // rotate
+ false, // useMediaBox
+ false, // crop
+ false); // printing
+ delete gerber_out;
+free_doc:
+ delete doc;
+ return ret;
+}
+