Skip to content

Commit 9afc0e9

Browse files
committed
Upgrading to JODConverter 3.0 beta 3. Adding PNG, GIF, JPG, TIF, and BMP to the list of supported input formats.
1 parent 18363f9 commit 9afc0e9

19 files changed

Lines changed: 243 additions & 1 deletion

lib/docsplit.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ def self.extract_images(pdfs, opts={})
5454
def self.extract_pdf(docs, opts={})
5555
[docs].flatten.each do |doc|
5656
basename = File.basename(doc, File.extname(doc))
57-
run "-jar #{ROOT}/vendor/jodconverter/jodconverter-cli-2.2.2.jar #{doc} #{opts[:output] || '.'}/#{basename}.pdf", [], {}
57+
options = "-jar #{ROOT}/vendor/jodconverter/jodconverter-core-3.0-beta-3.jar -r #{ROOT}/vendor/conf/document-formats.js"
58+
run "#{options} \"#{doc}\" \"#{opts[:output] || '.'}/#{basename}.pdf\"", [], {}
5859
end
5960
end
6061

test/fixtures/image.png

34.1 KB
Loading

test/unit/test_convert_to_pdf.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ def test_rtf_conversion
1212
assert Dir["#{OUTPUT}/*.pdf"] == ["#{OUTPUT}/obama_hopes.pdf"]
1313
end
1414

15+
def test_png_conversion
16+
Docsplit.extract_pdf('test/fixtures/image.png', :output => OUTPUT)
17+
assert Dir["#{OUTPUT}/*.pdf"] == ["#{OUTPUT}/image.pdf"]
18+
end
19+
1520
def test_conversion_then_page_extraction
1621
Docsplit.extract_pdf('test/fixtures/obama_veterans.doc', :output => OUTPUT)
1722
Docsplit.extract_pages("#{OUTPUT}/obama_veterans.pdf", :output => OUTPUT)

vendor/conf/document-formats.js

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
//
2+
// JODConverter Document Formats Configuration
3+
//
4+
[
5+
{
6+
"name": "Portable Document Format",
7+
"extension": "pdf",
8+
"mediaType": "application/pdf",
9+
"storePropertiesByFamily": {
10+
"DRAWING": {"FilterName": "draw_pdf_Export"},
11+
"SPREADSHEET": {"FilterName": "calc_pdf_Export"},
12+
"PRESENTATION": {"FilterName": "impress_pdf_Export"},
13+
"TEXT": {"FilterName": "writer_pdf_Export"}
14+
}
15+
},
16+
{
17+
"name": "Macromedia Flash",
18+
"extension": "swf",
19+
"mediaType": "application/x-shockwave-flash",
20+
"storePropertiesByFamily": {
21+
"DRAWING": {"FilterName": "draw_flash_Export"},
22+
"PRESENTATION": {"FilterName": "impress_flash_Export"}
23+
}
24+
},
25+
{
26+
"name": "HTML",
27+
"extension": "html",
28+
"mediaType": "text/html",
29+
"inputFamily": "TEXT",
30+
"storePropertiesByFamily": {
31+
"SPREADSHEET": {"FilterName": "HTML (StarCalc)"},
32+
"PRESENTATION": {"FilterName": "impress_html_Export"},
33+
"TEXT": {"FilterName": "HTML (StarWriter)"}
34+
}
35+
},
36+
{
37+
"name": "OpenDocument Text",
38+
"extension": "odt",
39+
"mediaType": "application/vnd.oasis.opendocument.text",
40+
"inputFamily": "TEXT",
41+
"storePropertiesByFamily": {"TEXT": {"FilterName": "writer8"}}
42+
},
43+
{
44+
"name": "OpenOffice.org 1.0 Text Document",
45+
"extension": "sxw",
46+
"mediaType": "application/vnd.sun.xml.writer",
47+
"inputFamily": "TEXT",
48+
"storePropertiesByFamily": {"TEXT": {"FilterName": "StarOffice XML (Writer)"}}
49+
},
50+
{
51+
"name": "Microsoft Word",
52+
"extension": "doc",
53+
"mediaType": "application/msword",
54+
"inputFamily": "TEXT",
55+
"storePropertiesByFamily": {"TEXT": {"FilterName": "MS Word 97"}}
56+
},
57+
{
58+
"name": "Microsoft Word 2007 XML",
59+
"extension": "docx",
60+
"mediaType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
61+
"inputFamily": "TEXT"
62+
},
63+
{
64+
"name": "Rich Text Format",
65+
"extension": "rtf",
66+
"mediaType": "text/rtf",
67+
"inputFamily": "TEXT",
68+
"storePropertiesByFamily": {"TEXT": {"FilterName": "Rich Text Format"}}
69+
},
70+
{
71+
"name": "WordPerfect",
72+
"extension": "wpd",
73+
"mediaType": "application/wordperfect",
74+
"inputFamily": "TEXT"
75+
},
76+
{
77+
"name": "Plain Text",
78+
"extension": "txt",
79+
"mediaType": "text/plain",
80+
"inputFamily": "TEXT",
81+
"loadProperties": {
82+
"FilterName": "Text (encoded)",
83+
"FilterOptions": "utf8"
84+
},
85+
"storePropertiesByFamily": {"TEXT": {
86+
"FilterName": "Text (encoded)",
87+
"FilterOptions": "utf8"
88+
}}
89+
},
90+
{
91+
"name": "MediaWiki wikitext",
92+
"extension": "wiki",
93+
"mediaType": "text/x-wiki",
94+
"storePropertiesByFamily": {"TEXT": {"FilterName": "MediaWiki"}}
95+
},
96+
{
97+
"name": "OpenDocument Spreadsheet",
98+
"extension": "ods",
99+
"mediaType": "application/vnd.oasis.opendocument.spreadsheet",
100+
"inputFamily": "SPREADSHEET",
101+
"storePropertiesByFamily": {"SPREADSHEET": {"FilterName": "calc8"}}
102+
},
103+
{
104+
"name": "OpenOffice.org 1.0 Spreadsheet",
105+
"extension": "sxc",
106+
"mediaType": "application/vnd.sun.xml.calc",
107+
"inputFamily": "SPREADSHEET",
108+
"storePropertiesByFamily": {"SPREADSHEET": {"FilterName": "StarOffice XML (Calc)"}}
109+
},
110+
{
111+
"name": "Microsoft Excel",
112+
"extension": "xls",
113+
"mediaType": "application/vnd.ms-excel",
114+
"inputFamily": "SPREADSHEET",
115+
"storePropertiesByFamily": {"SPREADSHEET": {"FilterName": "MS Excel 97"}}
116+
},
117+
{
118+
"name": "Microsoft Excel 2007 XML",
119+
"extension": "xlsx",
120+
"mediaType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
121+
"inputFamily": "SPREADSHEET"
122+
},
123+
{
124+
"name": "Comma Separated Values",
125+
"extension": "csv",
126+
"mediaType": "text/csv",
127+
"inputFamily": "SPREADSHEET",
128+
"loadProperties": {
129+
"FilterName": "Text - txt - csv (StarCalc)",
130+
"FilterOptions": "44,34,0"
131+
},
132+
"storePropertiesByFamily": {"SPREADSHEET": {
133+
"FilterName": "Text - txt - csv (StarCalc)",
134+
"FilterOptions": "44,34,0"
135+
}}
136+
},
137+
{
138+
"name": "Tab Separated Values",
139+
"extension": "tsv",
140+
"mediaType": "text/tab-separated-values",
141+
"inputFamily": "SPREADSHEET",
142+
"loadProperties": {
143+
"FilterName": "Text - txt - csv (StarCalc)",
144+
"FilterOptions": "9,34,0"
145+
},
146+
"storePropertiesByFamily": {"SPREADSHEET": {
147+
"FilterName": "Text - txt - csv (StarCalc)",
148+
"FilterOptions": "9,34,0"
149+
}}
150+
},
151+
{
152+
"name": "OpenDocument Presentation",
153+
"extension": "odp",
154+
"mediaType": "application/vnd.oasis.opendocument.presentation",
155+
"inputFamily": "PRESENTATION",
156+
"storePropertiesByFamily": {"PRESENTATION": {"FilterName": "impress8"}}
157+
},
158+
{
159+
"name": "OpenOffice.org 1.0 Presentation",
160+
"extension": "sxi",
161+
"mediaType": "application/vnd.sun.xml.impress",
162+
"inputFamily": "PRESENTATION",
163+
"storePropertiesByFamily": {"PRESENTATION": {"FilterName": "StarOffice XML (Impress)"}}
164+
},
165+
{
166+
"name": "Microsoft PowerPoint",
167+
"extension": "ppt",
168+
"mediaType": "application/vnd.ms-powerpoint",
169+
"inputFamily": "PRESENTATION",
170+
"storePropertiesByFamily": {"PRESENTATION": {"FilterName": "MS PowerPoint 97"}}
171+
},
172+
{
173+
"name": "Microsoft PowerPoint 2007 XML",
174+
"extension": "pptx",
175+
"mediaType": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
176+
"inputFamily": "PRESENTATION"
177+
},
178+
{
179+
"name": "OpenDocument Drawing",
180+
"extension": "odg",
181+
"mediaType": "application/vnd.oasis.opendocument.graphics",
182+
"inputFamily": "DRAWING",
183+
"storePropertiesByFamily": {"DRAWING": {"FilterName": "draw8"}}
184+
},
185+
{
186+
"name": "Scalable Vector Graphics",
187+
"extension": "svg",
188+
"mediaType": "image/svg+xml",
189+
"storePropertiesByFamily": {"DRAWING": {"FilterName": "draw_svg_Export"}}
190+
},
191+
{
192+
"name": "Portable Network Graphic",
193+
"extension": "png",
194+
"mediaType": "image/png",
195+
"storePropertiesByFamily": {
196+
"DRAWING": {"FilterName": "draw_png_Export"},
197+
"PRESENTATION": {"FilterName": "impress_png_Export"}
198+
}
199+
},
200+
{
201+
"name": "Graphics Interchange Format",
202+
"extension": "gif",
203+
"mediaType": "image/gif",
204+
"storePropertiesByFamily": {
205+
"DRAWING": {"FilterName": "draw_gif_Export"},
206+
"PRESENTATION": {"FilterName": "impress_gif_Export"}
207+
}
208+
},
209+
{
210+
"name": "Joint Photographic Experts Group",
211+
"extension": "jpg",
212+
"mediaType": "image/jpeg",
213+
"storePropertiesByFamily": {
214+
"DRAWING": {"FilterName": "draw_jpg_Export"},
215+
"PRESENTATION": {"FilterName": "impress_jpg_Export"}
216+
}
217+
},
218+
{
219+
"name": "Windows Bitmap",
220+
"extension": "bmp",
221+
"mediaType": "image/bmp",
222+
"storePropertiesByFamily": {
223+
"DRAWING": {"FilterName": "draw_bmp_Export"},
224+
"PRESENTATION": {"FilterName": "impress_bmp_Export"}
225+
}
226+
},
227+
{
228+
"name": "Tagged Image File Format",
229+
"extension": "tif",
230+
"mediaType": "image/tiff",
231+
"storePropertiesByFamily": {
232+
"DRAWING": {"FilterName": "draw_tif_Export"},
233+
"PRESENTATION": {"FilterName": "impress_tif_Export"}
234+
}
235+
}
236+
]
35.3 KB
Binary file not shown.
-40.2 KB
Binary file not shown.

vendor/jodconverter/commons-io-1.4.jar

100755100644
File mode changed.
-31.3 KB
Binary file not shown.
-5.58 KB
Binary file not shown.
64.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)