Last active
August 29, 2015 14:25
-
-
Save zudochkin/3a5240a684abe22ce174 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# gem install pdf_forms | |
if ARGV.size < 2 | |
puts "USAGE pdf-fill-out-checkboxes INPUT OUTPUT" | |
exit | |
end | |
require 'pdf_forms' | |
# On Linux | |
pdftk = PdfForms.new('/usr/bin/pdftk') | |
INPUT = ARGV.first | |
OUTPUT = ARGV.last | |
fields = pdftk.get_fields INPUT | |
data = {} | |
checkboxes = fields.select { |f| f.type != "Text" }.each { |f| data[f.name] = "Off" } | |
pdftk.fill_form INPUT, OUTPUT, data | |
puts "The following fields have been filled out :" | |
puts checkboxes.map(&:name).join(', ') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment