Class PDF::Reader::Page
In: lib/pdf/reader/page.rb
Parent: Object

high level representation of a single PDF page. Ties together the various low level classes in PDF::Reader and provides access to the various components of the page (text, images, fonts, etc) in convenient formats.

If you require access to the raw PDF objects for this page, you can access the Page dictionary via the page_object accessor. You will need to use the objects accessor to help walk the page dictionary in any useful way.

Methods

attributes   inspect   new   number   raw_content   text   to_s   walk  

Included Modules

ResourceMethods

Attributes

objects  [R]  lowlevel hash-like access to all objects in the underlying PDF
page_object  [R]  the raw PDF object that defines this page

Public Class methods

creates a new page wrapper.

  • objects - an ObjectHash instance that wraps a PDF file
  • pagenum - an int specifying the page number to expose. 1 indexed.

Public Instance methods

Returns the attributes that accompany this page, including attributes inherited from parents.

return a friendly string representation of this page

return the number of this page within the full document

returns the raw content stream for this page. This is plumbing, nothing to see here unless you‘re a PDF nerd like me.

returns the plain text content of this page encoded as UTF-8. Any characters that can‘t be translated will be returned as a ▯

to_s()

Alias for text

processes the raw content stream for this page in sequential order and passes callbacks to the receiver objects.

This is mostly low level and you can probably ignore it unless you need access to something like the raw encoded text. For an example of how this can be used as a basis for higher level functionality, see the text() method

If someone was motivated enough, this method is intended to provide all the data required to faithfully render the entire page. If you find some required data isn‘t available it‘s a bug - let me know.

Many operators that generate callbacks will reference resources stored in the page header - think images, fonts, etc. To facilitate these operators, the first available callback is page=. If your receiver accepts that callback it will be passed the current PDF::Reader::Page object. Use the Page#resources method to grab any required resources.

It may help to think of each page as a self contained program made up of a set of instructions and associated resources. Calling walk() executes the program in the correct order and calls out to your implementation.

[Validate]