Class: Preflight::Rules::MinBleed
- Inherits:
-
Object
- Object
- Preflight::Rules::MinBleed
- Extended by:
- Forwardable
- Includes:
- Measurements
- Defined in:
- lib/preflight/rules/min_bleed.rb
Overview
To print colour to the edge of the page you must print past the intended page edge and then trim the printed sheet. The printed area that will be trimmed is called bleed. Generally you will probably want 3-4mm of bleed.
Arguments: the distance from the TrimBox within which objects MUST include bleed
the distance past the TrimBox that objects MUST bleed
the units (:pt, :mm, :in)
Usage:
class MyPreflight
include Preflight::Profile
rule Preflight::Rules::MinBleed, 1, 4, :mm
rule Preflight::Rules::MinBleed, 12, 50, :pt
rule Preflight::Rules::MinBleed, 0.1, 0.25, :in
end
Instance Attribute Summary collapse
-
#issues ⇒ Object
readonly
Returns the value of attribute issues.
Instance Method Summary collapse
- #append_rectangle(x1, y1, x2, y2) ⇒ Object
- #close_and_stroke_path ⇒ Object
- #end_path ⇒ Object
- #fill_path_with_nonzero ⇒ Object (also: #fill_path_with_even_odd)
-
#initialize(range, bleed, units) ⇒ MinBleed
constructor
A new instance of MinBleed.
-
#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.
-
#page=(page) ⇒ Object
we’re about to start a new page, reset state.
- #stroke_path ⇒ Object
Constructor Details
#initialize(range, bleed, units) ⇒ MinBleed
Returns a new instance of MinBleed.
39 40 41 |
# File 'lib/preflight/rules/min_bleed.rb', line 39 def initialize(range, bleed, units) @range, @bleed, @units = range, bleed, units end |
Instance Attribute Details
#issues ⇒ Object (readonly)
Returns the value of attribute issues.
31 32 33 |
# File 'lib/preflight/rules/min_bleed.rb', line 31 def issues @issues end |
Instance Method Details
#append_rectangle(x1, y1, x2, y2) ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/preflight/rules/min_bleed.rb', line 79 def append_rectangle(x1, y1, x2, y2) @path ||= [] @path << @state.ctm_transform(x1, y1) @path << @state.ctm_transform(x1, y2) @path << @state.ctm_transform(x2, y1) @path << @state.ctm_transform(x2, y2) end |
#close_and_stroke_path ⇒ Object
102 103 104 |
# File 'lib/preflight/rules/min_bleed.rb', line 102 def close_and_stroke_path @path = [] end |
#end_path ⇒ Object
110 111 112 |
# File 'lib/preflight/rules/min_bleed.rb', line 110 def end_path @path = [] end |
#fill_path_with_nonzero ⇒ Object Also known as: fill_path_with_even_odd
87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/preflight/rules/min_bleed.rb', line 87 def fill_path_with_nonzero @path ||= [] points = select_points_in_danger_zone(@path) if points.size > 0 @issues << Issue.new("Filled object with insufficient bleed", self, :page => @page.number, :object_type => :filled_object, :bleed => @bleed, :units => @units) end @path = [] end |
#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.
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/preflight/rules/min_bleed.rb', line 66 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 else raise xobj.inspect end end end |
#page=(page) ⇒ Object
we’re about to start a new page, reset state
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/preflight/rules/min_bleed.rb', line 45 def page=(page) @issues = [] @page = page @state = PDF::Reader::PageState.new(page) @objects = page.objects attrs = @page.attributes box = attrs[:TrimBox] || attrs[:ArtBox] || attrs[:MediaBox] @warning_min_x = box[0] + to_points(@range, @units) @warning_min_y = box[1] + to_points(@range, @units) @warning_max_x = box[2] - to_points(@range, @units) @warning_max_y = box[3] - to_points(@range, @units) @error_min_x = box[0] - to_points(@bleed, @units) @error_min_y = box[1] - to_points(@bleed, @units) @error_max_x = box[2] + to_points(@bleed, @units) @error_max_y = box[3] + to_points(@bleed, @units) end |
#stroke_path ⇒ Object
106 107 108 |
# File 'lib/preflight/rules/min_bleed.rb', line 106 def stroke_path @path = [] end |