Module: DerivativeRodeo::Services::PdfSplitter

Defined in:
lib/derivative_rodeo/services/pdf_splitter/base.rb,
lib/derivative_rodeo/services/pdf_splitter/jpg_page.rb,
lib/derivative_rodeo/services/pdf_splitter/png_page.rb,
lib/derivative_rodeo/services/pdf_splitter/tiff_page.rb,
lib/derivative_rodeo/services/pdf_splitter/pages_summary.rb

Overview

A service module for splitting PDFs into one image per page.

See Also:

Defined Under Namespace

Classes: Base, JpgPage, PagesSummary, PngPage, TiffPage

Class Method Summary collapse

Class Method Details

.call(path, image_extension:, image_file_basename_template:) ⇒ Enumerable, ...

Split the file found at the given :path

Parameters:

  • path (String)

    the path to the source PDF that we’re processing.

  • image_extension (String)

    used to determine the splitting service we use; there is an implicit relationship between image_extension and image_file_basename_template (though filenames do not necessarily reflect mime types)

  • image_file_basename_template (String)

    use this string to generate the unique filename for an image “split” from the given PDF. It must include “%d” as part of the declaration. For example if the template is “hello-world-%d.png” then the first split page will be “hello-world-1.png”.

Returns:



27
28
29
30
31
# File 'lib/derivative_rodeo/services/pdf_splitter/base.rb', line 27

def self.call(path, image_extension:, image_file_basename_template:)
  klass_name = "#{image_extension.to_s.classify}_page".classify
  klass = "DerivativeRodeo::Services::PdfSplitter::#{klass_name}".constantize
  klass.new(path, image_file_basename_template: image_file_basename_template)
end