On May 16, 2020, Jolly Roger wrote
(in article <
hib1sa...@mid.individual.net>):
> I've done this PDF document validation in Ruby using the pdf-reader Gem
> before. Here's a simplified example script:
>
> ---
> #!/usr/bin/env ruby
>
> require 'pdf-reader' # gem install 'pdf-reader'
>
> class Reader
> def start
> filepath = ARGV[0]
> unless filepath.nil?
> if File.exist?(filepath)
> begin
> reader = PDF::Reader.new(filepath)
> puts "Document is valid: #{File.basename(filepath)}"
> rescue StandardError => exception
> puts "Couldn't open #{File.basename(filepath)}: #{exception.message}"
> end
> else
> STDERR.puts "ERROR: Specified file does not exist: #{filepath}"
> end
> else
> STDERR.puts "ERROR: You must provide the path to a PDF document as the first
> command-line argument."
> end
> end
> end
>
> reader = Reader.new()
> reader.start()
> ---
>
> Usage examples:
>
> ---
> #./pdf_validator.rb ~/Documents/Hardware/Car\ Stereo/Old/KAC818.pdf
> PDF seems valid: KAC818.pdf
>
> # ./pdf_validator.rb some_bad.pdf
> PDF does not contain EOF marker: some_bad.pdf
> ---
>
> You could certainly wrap this in an AppleScript "do shell script"
> command to automate it if you wanted to. But I'd probably just modify
> the script to do exactly what I want and run it on the command line and
> be done with it.
If I knew something about Ruby (other than just what is “is” I would work
with this, but I don’t. But thanks much.