Skip to content

Commit

Permalink
Add timeout option to JODConverter.
Browse files Browse the repository at this point in the history
Original work by documentcloud#34 with
modification to not use a default timeout (causing no change from
existing functionality).
  • Loading branch information
Doug Mayer committed Apr 25, 2014
1 parent 63642eb commit 856b122
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ <h2 id="usage">Usage</h2>
<b>xls</b> and so on, as well as <b>html</b>, <b>odf</b>, <b>rtf</b>, <b>swf</b>, <b>svg</b>, and <b>wpd</b>.
The first time that you convert a new file type, LibreOffice will lazy-load
the code that processes it &mdash; subsequent conversions will be much faster.
<br />
The <tt>--timeout</tt> flag may be used to set the number of seconds before
JODConverter's "error on timeout" exception. Useful when you convert very large documents.
</p>
<pre>
docsplit pdf documentation/*.html</pre>
Expand Down
5 changes: 4 additions & 1 deletion lib/docsplit/command_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def parse_options
opts.on('-r', '--rolling', 'generate images from each previous image') do |r|
@options[:rolling] = true
end
opts.on('-t', '--timeout', 'Timeout for PDF extraction from OpenOffice-supported document format') do |t|
@options[:timeout] = t
end
opts.on_tail('-v', '--version', 'display docsplit version') do
puts "Docsplit version #{Docsplit::VERSION}"
exit
Expand All @@ -120,4 +123,4 @@ def parse_options

end

end
end
2 changes: 2 additions & 0 deletions lib/docsplit/pdf_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def office_path
# Convert documents to PDF.
def extract(docs, opts)
out = opts[:output] || '.'
timeout = opts[:timeout]
FileUtils.mkdir_p out unless File.exists?(out)
[docs].flatten.each do |doc|
ext = File.extname(doc)
Expand All @@ -132,6 +133,7 @@ def extract(docs, opts)
true
else # open office presumably, rely on JODConverter to figure it out.
options = "-jar #{ESCAPED_ROOT}/vendor/jodconverter/jodconverter-core-3.0-beta-4.jar -r #{ESCAPED_ROOT}/vendor/conf/document-formats.js"
options += "-t #{timeout}" if timeout
run_jod "#{options} #{escaped_doc} #{escaped_out}/#{escaped_basename}.pdf", [], {}
end
end
Expand Down

0 comments on commit 856b122

Please sign in to comment.