Class: PDF::Reader::FormXObject
- Inherits:
-
Object
- Object
- PDF::Reader::FormXObject
- Includes:
- ResourceMethods
- Defined in:
- lib/pdf/reader/form_xobject.rb
Overview
High level representation of a single PDF form xobject. Form xobjects are contained pieces of content that can be inserted onto multiple pages. They’re generally used as a space efficient way to store repetative content (like logos, header, footers, etc).
This behaves and looks much like a limited PDF::Reader::Page class.
Instance Attribute Summary collapse
-
#xobject ⇒ Object
readonly
Returns the value of attribute xobject.
Instance Method Summary collapse
-
#font_objects ⇒ Object
return a hash of fonts used on this form.
-
#initialize(page, xobject) ⇒ FormXObject
constructor
A new instance of FormXObject.
-
#raw_content ⇒ Object
returns the raw content stream for this page.
-
#walk(*receivers) ⇒ Object
processes the raw content stream for this form in sequential order and passes callbacks to the receiver objects.
Methods included from ResourceMethods
#color_spaces, #fonts, #graphic_states, #patterns, #procedure_sets, #properties, #shadings, #xobjects
Constructor Details
#initialize(page, xobject) ⇒ FormXObject
Returns a new instance of FormXObject.
18 19 20 21 22 |
# File 'lib/pdf/reader/form_xobject.rb', line 18 def initialize(page, xobject) @page = page @objects = page.objects @xobject = @objects.deref(xobject) end |
Instance Attribute Details
#xobject ⇒ Object (readonly)
Returns the value of attribute xobject.
16 17 18 |
# File 'lib/pdf/reader/form_xobject.rb', line 16 def xobject @xobject end |
Instance Method Details
#font_objects ⇒ Object
return a hash of fonts used on this form.
The keys are the font labels used within the form content stream.
The values are a PDF::Reader::Font instances that provide access to most available metrics for each font.
31 32 33 34 35 36 |
# File 'lib/pdf/reader/form_xobject.rb', line 31 def font_objects raw_fonts = @objects.deref(resources[:Font] || {}) ::Hash[raw_fonts.map { |label, font| [label, PDF::Reader::Font.new(@objects, @objects.deref(font))] }] end |
#raw_content ⇒ Object
returns the raw content stream for this page. This is plumbing, nothing to see here unless you’re a PDF nerd like me.
50 51 52 |
# File 'lib/pdf/reader/form_xobject.rb', line 50 def raw_content @xobject.unfiltered_data end |
#walk(*receivers) ⇒ Object
processes the raw content stream for this form in sequential order and passes callbacks to the receiver objects.
See the comments on PDF::Reader::Page#walk for more detail.
43 44 45 |
# File 'lib/pdf/reader/form_xobject.rb', line 43 def walk(*receivers) content_stream(receivers, raw_content) end |