Class: Rpdfium::TextPage
- Inherits:
-
Object
- Object
- Rpdfium::TextPage
- Defined in:
- lib/rpdfium/page.rb
Overview
Wrapper for 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.
1623 1624 1625 1626 1627 1628 1629 |
# File 'lib/rpdfium/page.rb', line 1623 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
1631 1632 1633 1634 1635 1636 1637 1638 1639 |
# File 'lib/rpdfium/page.rb', line 1631 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
1645 1646 1647 |
# File 'lib/rpdfium/page.rb', line 1645 def char_count Raw.FPDFText_CountChars(@state[:handle]) end |
#close ⇒ Object
1649 1650 1651 1652 1653 1654 1655 1656 |
# File 'lib/rpdfium/page.rb', line 1649 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
1641 1642 1643 |
# File 'lib/rpdfium/page.rb', line 1641 def handle @state[:handle] end |