Sha256: 0eb564d96a33dc7c087db8ebabe18b130b399d18f98a0304f68b271bd9a0572d

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

# frozen_string_literal: true

module MuPDF
  # A wrapper for a PDF document allowing for MuPDF APIs.
  class Document
    # @param pathname [Pathname]
    def initialize(pathname)
      @pathname = pathname
    end

    # @return [String]
    def inspect
      "#<#{self.class.name} pathname=#{@pathname}>"
    end

    # @raise [MuPDF::CommandError]
    #
    # @return [MuPDF::Info]
    def info
      @info ||= begin
        result = MuPDF.mutool('info', String(@pathname))
        MuPDF::Info.parse(result)
      end
    end

    # @raise [MuPDF::CommandError]
    #
    # @return [Array<MuPDF::Page>]
    def pages
      @pages ||= begin
        result = MuPDF.mutool('pages', String(@pathname))
        MuPDF::Page.parse(result)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mupdf-0.4.0 lib/mupdf/document.rb