module HexaPDF::ImageLoader::PDF

def self.handles?(file_or_io)

in JPEG format.
Returns +true+ if the given file or IO stream can be handled, ie. if it contains an image

PDF.handles?(io) -> true or false
PDF.handles?(filename) -> true or false
:call-seq:
def self.handles?(file_or_io)
  if file_or_io.kind_of?(String)
    File.read(file_or_io, 5, mode: 'rb') == MAGIC_FILE_MARKER
  else
    file_or_io.rewind
    file_or_io.read(5) == MAGIC_FILE_MARKER
  end
end

def self.load(document, file_or_io)

See: DefaultConfiguration for the meaning of 'image_loader.pdf.use_stringio'.

Creates a PDF form XObject from the PDF file or IO stream.

PDF.load(document, io) -> form_obj
PDF.load(document, filename) -> form_obj
:call-seq:
def self.load(document, file_or_io)
  idoc = if file_or_io.kind_of?(String) && document.config['image_loader.pdf.use_stringio']
           HexaPDF::Document.open(file_or_io)
         elsif file_or_io.kind_of?(String)
           HexaPDF::Document.new(io: File.open(file_or_io, 'rb'))
         else
           HexaPDF::Document.new(io: file_or_io)
         end
  form = idoc.pages[0].to_form_xobject
  document.add(document.import(form))
end