Class: Preflight::Rules::MinPpi

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Measurements
Defined in:
lib/preflight/rules/min_ppi.rb

Overview

For high quality prints, you generally want raster images to be AT LEAST 300 points-per-inch (ppi). 600 is better, 1200 better again.

Arguments: the lowest PPI that is ok

Usage:

class MyPreflight
  include Preflight::Profile

  rule Preflight::Rules::MinPpi, 300
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(min_ppi) ⇒ MinPpi

Returns a new instance of MinPpi.



34
35
36
# File 'lib/preflight/rules/min_ppi.rb', line 34

def initialize(min_ppi)
  @min_ppi = min_ppi.to_i
end

Instance Attribute Details

#issuesObject (readonly)

Returns the value of attribute issues.



26
27
28
# File 'lib/preflight/rules/min_ppi.rb', line 26

def issues
  @issues
end

Instance Method Details

#invoke_xobject(label) ⇒ Object

As each image is drawn on the canvas, determine the amount of device space it’s being crammed into and therefore the PPI.



49
50
51
52
53
54
55
56
57
58
# File 'lib/preflight/rules/min_ppi.rb', line 49

def invoke_xobject(label)
  @state.invoke_xobject(label) do |xobj|
    case xobj
    when PDF::Reader::FormXObject then
      xobj.walk(self)
    when PDF::Reader::Stream
      invoke_image_xobject(xobj) if xobj.hash[:Subtype] == :Image
    end
  end
end

#page=(page) ⇒ Object

we’re about to start a new page, reset state



40
41
42
43
44
# File 'lib/preflight/rules/min_ppi.rb', line 40

def page=(page)
  @page   = page
  @state  = PDF::Reader::PageState.new(page)
  @issues = []
end