Class: Pdfrb::Document::Stamps
- Inherits:
-
Object
- Object
- Pdfrb::Document::Stamps
- Defined in:
- lib/pdfrb/document/stamps.rb
Overview
Page stamping facade. Stamps a Form XObject (logo, watermark, page number) onto every page of the document by emitting the Do operator in each page's content stream.
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
-
#initialize(document) ⇒ Stamps
constructor
A new instance of Stamps.
-
#stamp_everywhere(form_xobject, at: [0, 0]) ⇒ Symbol
Stamp a Form XObject on every page.
-
#stamp_page(page, form_xobject, at: [0, 0]) ⇒ Object
Stamp a Form XObject on a single page.
Constructor Details
#initialize(document) ⇒ Stamps
Returns a new instance of Stamps.
11 12 13 |
# File 'lib/pdfrb/document/stamps.rb', line 11 def initialize(document) @document = document end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
9 10 11 |
# File 'lib/pdfrb/document/stamps.rb', line 9 def document @document end |
Instance Method Details
#stamp_everywhere(form_xobject, at: [0, 0]) ⇒ Symbol
Stamp a Form XObject on every page.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/pdfrb/document/stamps.rb', line 20 def stamp_everywhere(form_xobject, at: [0, 0]) name = next_stamp_name ref = Pdfrb::Model::Reference.new(form_xobject.oid, form_xobject.gen) document.pages.each do |page| register_xobject_in_resources(page, name, ref) emit_do_operator(page, name, at) end name end |
#stamp_page(page, form_xobject, at: [0, 0]) ⇒ Object
Stamp a Form XObject on a single page.
32 33 34 35 36 37 38 |
# File 'lib/pdfrb/document/stamps.rb', line 32 def stamp_page(page, form_xobject, at: [0, 0]) name = next_stamp_name ref = Pdfrb::Model::Reference.new(form_xobject.oid, form_xobject.gen) register_xobject_in_resources(page, name, ref) emit_do_operator(page, name, at) name end |