lib/hexapdf/document.rb in hexapdf-0.1.0 vs lib/hexapdf/document.rb in hexapdf-0.2.0

- old
+ new

@@ -43,14 +43,12 @@ require 'hexapdf/task' require 'hexapdf/encryption' require 'hexapdf/writer' require 'hexapdf/importer' require 'hexapdf/image_loader' -require 'hexapdf/document_utils' -require 'hexapdf/font_utils' +require 'hexapdf/font_loader' - # == HexaPDF API Documentation # # Here are some pointers to more in depth information: # # * For information about the command line application, see the HexaPDF::CLI module. @@ -67,10 +65,15 @@ # # Note: This class provides everything to work on PDF documents on a low-level basis. This means # that there are no convenience methods for higher PDF functionality whatsoever. class Document + autoload(:Pages, 'hexapdf/document/pages') + autoload(:Fonts, 'hexapdf/document/fonts') + autoload(:Images, 'hexapdf/document/images') + autoload(:Files, 'hexapdf/document/files') + # :call-seq: # Document.open(filename, **docargs) -> doc # Document.open(filename, **docargs) {|doc| block} -> obj # # Creates a new PDF Document object for the given file. @@ -413,19 +416,30 @@ # Dispatches the message +name+ with the given arguments to all registered listeners. def dispatch_message(name, *args) @listeners[name] && @listeners[name].each {|obj| obj.call(*args)} end - # Returns a DocumentUtils object that provides convenience methods for often used - # functionality like adding images. - def utils - @utils ||= DocumentUtils.new(self) + # Returns the Pages object that provides convenience methods for working with pages. + # + # Also see: HexaPDF::Type::PageTreeNode + def pages + @pages ||= Pages.new(self) end - # Returns the FontUtils object that provides convenience methods for working with fonts. + # Returns the Images object that provides convenience methods for working with images. + def images + @images ||= Images.new(self) + end + + # Returns the Files object that provides convenience methods for working with files. + def files + @files ||= Files.new(self) + end + + # Returns the Fonts object that provides convenience methods for working with fonts. def fonts - @font_utils ||= FontUtils.new(self) + @fonts ||= Fonts.new(self) end # Executes the given task and returns its result. # # Tasks provide an extensible way for performing operations on a PDF document without @@ -445,16 +459,9 @@ end # Returns the document's catalog, the root of the object tree. def catalog trailer.catalog - end - - # Returns the root node of the document's page tree. - # - # See: HexaPDF::Type::PageTreeNode - def pages - catalog.pages end # Returns the PDF document's version as string (e.g. '1.4'). # # This method takes the file header version and the catalog's /Version key into account. If a