Class: Rpdfium::TextPage
- Inherits:
-
Object
- Object
- Rpdfium::TextPage
- Defined in:
- lib/rpdfium/page.rb
Overview
Wrapper per FPDF_TEXTPAGE
Class Method Summary collapse
Instance Method Summary collapse
- #char_count ⇒ Object
- #close ⇒ Object
- #handle ⇒ Object
-
#initialize(page) ⇒ TextPage
constructor
A new instance of TextPage.
Constructor Details
#initialize(page) ⇒ TextPage
Returns a new instance of TextPage.
1588 1589 1590 1591 1592 1593 1594 |
# File 'lib/rpdfium/page.rb', line 1588 def initialize(page) handle = Raw.FPDFText_LoadPage(page.handle) raise PageError, "Could not load text page" if handle.null? @state = { handle: handle, closed: false } ObjectSpace.define_finalizer(self, self.class.finalizer(@state)) end |
Class Method Details
.finalizer(state) ⇒ Object
1596 1597 1598 1599 1600 1601 1602 1603 1604 |
# File 'lib/rpdfium/page.rb', line 1596 def self.finalizer(state) proc do next if state[:closed] next if state[:handle].null? Raw.FPDFText_ClosePage(state[:handle]) state[:closed] = true end end |
Instance Method Details
#char_count ⇒ Object
1610 1611 1612 |
# File 'lib/rpdfium/page.rb', line 1610 def char_count Raw.FPDFText_CountChars(@state[:handle]) end |
#close ⇒ Object
1614 1615 1616 1617 1618 1619 1620 1621 |
# File 'lib/rpdfium/page.rb', line 1614 def close return if @state[:closed] Raw.FPDFText_ClosePage(@state[:handle]) unless @state[:handle].null? @state[:handle] = FFI::Pointer::NULL @state[:closed] = true ObjectSpace.undefine_finalizer(self) end |
#handle ⇒ Object
1606 1607 1608 |
# File 'lib/rpdfium/page.rb', line 1606 def handle @state[:handle] end |