Guest User

Untitled

a guest
Feb 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. im = "C:\\Program Files\\ImageMagick-7.0.7-Q16\\magick.exe"
  2. c2t = "H:\\Users\\Giovanni\\Downloads\\Capture2Text_v4.5.1_64bit\\Capture2Text_CLI.exe"
  3.  
  4. Dir.mkdir('res') unless Dir.exists?('res')
  5.  
  6. require 'thread/pool'
  7. pool = Thread.pool(8)
  8.  
  9. Dir['*.png'].each do |f|
  10. pool.process {
  11. `"#{im}" convert \"#{f}\" -transparent white "res/#{f}"`
  12. `"#{c2t}" --vertical -l Japanese -i "res/#{f}" -b --trim-capture --deskew -o "res/#{f}.txt"`
  13. }
  14. end
  15.  
  16. pool.shutdown
  17.  
  18. require "prawn"
  19.  
  20. Prawn::Document.generate("output.pdf") do
  21. font "mona.ttf"
  22.  
  23. Dir['res/*.txt'].each do |f|
  24. text File.open(f, "r:UTF-8", &:read)
  25. start_new_page
  26. end
  27. end
Add Comment
Please, Sign In to add comment