Skip to content

Commit fa6835e

Browse files
committed
Windows: "%d" is always escaped to "\%d".
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.
1 parent 6e58979 commit fa6835e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

lib/docsplit/page_extractor.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ def extract(pdfs, opts)
99
extract_options opts
1010
[pdfs].flatten.each do |pdf|
1111
pdf_name = File.basename(pdf, File.extname(pdf))
12-
page_path = File.join(@output, "#{pdf_name}_%d.pdf")
12+
page_path = ESCAPE[File.join(@output, "#{pdf_name}")] + "_%d.pdf"
1313
FileUtils.mkdir_p @output unless File.exists?(@output)
1414

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

3434
end
3535

36-
end
36+
end

0 commit comments

Comments
 (0)