Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- im = "C:\\Program Files\\ImageMagick-7.0.7-Q16\\magick.exe"
- c2t = "H:\\Users\\Giovanni\\Downloads\\Capture2Text_v4.5.1_64bit\\Capture2Text_CLI.exe"
- Dir.mkdir('res') unless Dir.exists?('res')
- require 'thread/pool'
- pool = Thread.pool(8)
- Dir['*.png'].each do |f|
- pool.process {
- `"#{im}" convert \"#{f}\" -transparent white "res/#{f}"`
- `"#{c2t}" --vertical -l Japanese -i "res/#{f}" -b --trim-capture --deskew -o "res/#{f}.txt"`
- }
- end
- pool.shutdown
- require "prawn"
- Prawn::Document.generate("output.pdf") do
- font "mona.ttf"
- Dir['res/*.txt'].each do |f|
- text File.open(f, "r:UTF-8", &:read)
- start_new_page
- end
- end
Add Comment
Please, Sign In to add comment