aboutsummaryrefslogtreecommitdiff
path: root/src/main.cc
blob: ecb986be4de16a3fc7560044bf4349ae5f913ebe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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;
}