Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
The PDF::Reader library implements a PDF parser conforming as much as possible to the PDF specification from Adobe.
Ruby

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
bin
lib
spec
.gitignore
CHANGELOG
Gemfile
README.rdoc
Rakefile
preflight.gemspec

README.rdoc

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.

Unlike some preflight tools, this library doesn't attempt to fix any issues. It only reports them. That may change one day, but for now you will need to fix any issues that are detected by using some other tool.

Installation

gem install preflight

Usage

Standard Profile ( PDF/X-1a )

To test a PDF file against a well known standard and rule set.

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

Create a custom set of rules to check against.

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.new

puts preflight.check("somefile.pdf").inspect

Extend A Profile

Use an existing rule set as the base for a larger set of rules.

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.new

puts preflight.check("somefile.pdf").inspect

Adding Rules to a Profile Instance

Dynamically add rules to a profile instance. Useful when the required set of rules depends dynamic conditions like user input or database entries.

require "preflight"

preflight = Preflight::Profiles::PDFX1A.new
prefight.rule Preflight::Rules::MaxVersion, 1.4

puts preflight.check("somefile.pdf").inspect

Status

This library is in an early stage of development. Use at your own risk.

Compatibility

This is pure ruby should run on most ruby VMs. I develop on MRI 1.9.2.

Further Reading

Something went wrong with that request. Please try again.