-
Notifications
You must be signed in to change notification settings - Fork 13
/
PDF2Table.java
87 lines (76 loc) · 3.44 KB
/
PDF2Table.java
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/*
Copyright 2005, 2005 Burcu Yildiz
Contact: burcu.yildiz@gmail.com
This file is part of pdf2table.
pdf2table 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.
pdf2table 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 pdf2table. If not, see <http://www.gnu.org/licenses/>.
*/
import java.io.File;
import pdf2xml.PDF2XML;
import pdf2xml.MainFrame;
public class PDF2Table {
public static void main(String args[]) {
try {
if (args.length == 0) {
MainFrame uid = new MainFrame();
uid.setVisible(true);
} else if (args.length == 2) {
File source = new File(args[0]);
File target = new File(args[1]);
if (source.isFile() && target.isDirectory()) {
String file_name = source.getName();
if (file_name.endsWith(".pdf")) {
int i = file_name.indexOf(".pdf");
file_name = file_name.substring(0, i);
PDF2XML.convert(file_name,
source.toString(), target + File.separator
+ file_name.toString(), "", "", false);
} else {
throw new Exception(
"The source file must be a PDF file (example.pdf)!");
}
} else {
throw new Exception();
}
} else if (args.length == 4) {
File source = new File(args[0]);
File target = new File(args[1]);
if (source.isFile() && target.isDirectory()) {
String file_name = source.getName();
if (file_name.endsWith(".pdf")) {
int i = file_name.indexOf(".pdf");
file_name = file_name.substring(0, i);
PDF2XML.convert(file_name,
source.toString(), target.toString()
+ File.separator + file_name, args[2],
args[3], false);
} else {
throw new Exception(
"The source file must be a PDF file (example.pdf)!");
}
} else {
throw new Exception();
}
} else {
throw new Exception();
}
} catch (Exception e) {
System.out
.println("Usage: pdf2table [<PDF-file> <target>] [<f> <l>]");
System.out
.println(" PDF-file <String> : PDF file with an '.pdf' ending");
System.out
.println(" target <String> : folder for the returned documents");
System.out.println(" f <int> : first page to extract");
System.out.println(" l <int> : last page to extract");
}
}
}