Class: Preflight::Rules::PrintBoxes

Inherits:
Object
  • Object
show all
Defined in:
lib/preflight/rules/print_boxes.rb

Overview

For PDFX/1a, every page must have MediaBox, plus either ArtBox or TrimBox

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePrintBoxes

Returns a new instance of PrintBoxes.



12
13
14
15
16
# File 'lib/preflight/rules/print_boxes.rb', line 12

def initialize
  @messages = []
  @page_num = 0
  @parent   = {}
end

Instance Attribute Details

#messagesObject (readonly)

Returns the value of attribute messages.



10
11
12
# File 'lib/preflight/rules/print_boxes.rb', line 10

def messages
  @messages
end

Instance Method Details

#begin_page(hash = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/preflight/rules/print_boxes.rb', line 22

def begin_page(hash = {})
  @page_num += 1
  hash = @parent.merge(hash)

  if hash[:MediaBox].nil?
    @messages << "every page must have a MediaBox (page #{@page_num})"
  elsif hash[:ArtBox].nil? && hash[:TrimBox].nil?
    @messages << "every page must have either an ArtBox or a TrimBox (page #{@page_num})"
  elsif hash[:ArtBox] && hash[:TrimBox]
    @messages << "no page can have both ArtBox and TrimBox - TrimBox is preferred (page #{@page_num})"
  end
end

#begin_page_container(hash = {}) ⇒ Object



18
19
20
# File 'lib/preflight/rules/print_boxes.rb', line 18

def begin_page_container(hash = {})
  @parent.merge!(hash)
end