Method: PDF::Core::Page#initialize

Defined in:
lib/pdf/core/page.rb

#initialize(document, options = {}) ⇒ Page

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Page.

Parameters:

  • document (Prawn::Document)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :margins (Hash{:left, :right, :top, :bottom => Number}, nil) — default: { left: 0, right: 0, top: 0, bottom: 0 }

    Page margins

  • :crop (Hash{:left, :right, :top, :bottom => Number}, nil) — default: ZERO_INDENTS

    Page crop box

  • :bleed (Hash{:left, :right, :top, :bottom => Number}, nil) — default: ZERO_INDENTS

    Page bleed box

  • :trims (Hash{:left, :right, :top, :bottom => Number}, nil) — default: ZERO_INDENTS

    Page trim box

  • :art_indents (Hash{:left, :right, :top, :bottom => Number}, Numeric)

    , nil] (ZERO_INDENTS) Page art box indents.

  • :graphic_state (PDF::Core::GraphicState, nil) — default: nil

    Initial graphic state

  • :size (String, Array<Numeric>, nil) — default: 'LETTER'

    Page size. A string identifies a named page size defined in PDF::Core::PageGeometry. An array must be a two element array specifying width and height in points.

  • :layout (:portrait, :landscape, nil) — default: :portrait

    Page orientation.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/pdf/core/page.rb', line 84

def initialize(document, options = {})
  @document = document
  @margins = options[:margins] || {
    left: 36,
    right: 36,
    top: 36,
    bottom: 36,
  }
  @crops = options[:crops] || ZERO_INDENTS
  @bleeds = options[:bleeds] || ZERO_INDENTS
  @trims = options[:trims] || ZERO_INDENTS
  @art_indents = options[:art_indents] || ZERO_INDENTS
  @stack = GraphicStateStack.new(options[:graphic_state])
  @size = options[:size] || 'LETTER'
  @layout = options[:layout] || :portrait

  @stamp_stream = nil
  @stamp_dictionary = nil

  @content = document.ref({})
  content << 'q' << "\n"
  @dictionary = document.ref(
    Type: :Page,
    Parent: document.state.store.pages,
    MediaBox: dimensions,
    CropBox: crop_box,
    BleedBox: bleed_box,
    TrimBox: trim_box,
    ArtBox: art_box,
    Contents: content,
  )

  resources[:ProcSet] = i[PDF Text ImageB ImageC ImageI]
end