Skip to content

Commit

Permalink
Windows: "%d" is always escaped to "\%d".
Browse files Browse the repository at this point in the history
Unders Windows, "%d" is always escaped to "\%d". It makes "extract_pages" fail because of below exception.

Docsplit::ExtractionFailed: Unhandled Java Exception in create_output():
java.io.FileNotFoundException: ./abc_\1.pdf: The system cannot find the path specified.
  • Loading branch information
ypxing committed Oct 14, 2014
1 parent 6e58979 commit fa6835e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/docsplit/page_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ def extract(pdfs, opts)
extract_options opts
[pdfs].flatten.each do |pdf|
pdf_name = File.basename(pdf, File.extname(pdf))
page_path = File.join(@output, "#{pdf_name}_%d.pdf")
page_path = ESCAPE[File.join(@output, "#{pdf_name}")] + "_%d.pdf"
FileUtils.mkdir_p @output unless File.exists?(@output)

cmd = if DEPENDENCIES[:pdftailor] # prefer pdftailor, but keep pdftk for backwards compatability
"pdftailor unstitch --output #{ESCAPE[page_path]} #{ESCAPE[pdf]} 2>&1"
"pdftailor unstitch --output #{page_path} #{ESCAPE[pdf]} 2>&1"
else
"pdftk #{ESCAPE[pdf]} burst output #{ESCAPE[page_path]} 2>&1"
"pdftk #{ESCAPE[pdf]} burst output #{page_path} 2>&1"
end
result = `#{cmd}`.chomp
FileUtils.rm('doc_data.txt') if File.exists?('doc_data.txt')
Expand All @@ -33,4 +33,4 @@ def extract_options(options)

end

end
end

0 comments on commit fa6835e

Please sign in to comment.