Preflight
Check your PDF files meet the standard you require.
The full PDF spec is a beast, and there are any number of ways of producing a valid PDF. Receivers of PDF files may need to ensure the files they’re sent meet a particular set of requirements, be it PDF/X, PDF/A or just “images must be 300 dpi or greater”. These checks are called preflight.
There’s expensive software around that can preflight for you, but it’s often difficult to script and you know, expensive.
This may not check as comprehensively as the official preflight tools from Adobe and friends, but hopefully it’ll get you most of the way with less stress.
Installation
gem install preflight
Usage
Standard Profile ( PDF/X-1a )
require "preflight"
preflight = Preflight::Profiles::PDFX1A.new
puts preflight.check("somefile.pdf").inspect
File.open("somefile.pdf", "rb") do |file|
puts preflight.check(file).inspect
end
Custom Profile
require "preflight"
class MyPreflight
include Preflight::Profile
profile_name "simple-pdf"
rule Preflight::Rules::MaxVersion, 1.4
rule Preflight::Rules::NoEncryption
rule Preflight::Rules::DocumentId
end
preflight = MyPreflight
puts preflight.check("somefile.pdf").inspect
Extend A Profile
require "preflight"
class MyPreflight
include Preflight::Profile
profile_name "simple-pdf"
import Preflight::Profiles::PDFX1A
rule Preflight::Rules::MaxVersion, 1.4
rule Preflight::Rules::NoEncryption
rule Preflight::Rules::DocumentId
end
preflight = MyPreflight
puts preflight.check("somefile.pdf").inspect
Status
This library is in an early stage of development. Use at your own risk.
Compatability
This is pure ruby should run on most ruby VMs. I develop on MRI 1.9.2.