Class: IiifPrint::SplitPdfs::BaseSplitter Abstract
- Inherits:
-
Object
- Object
- IiifPrint::SplitPdfs::BaseSplitter
- Includes:
- Enumerable
- Defined in:
- lib/iiif_print/split_pdfs/base_splitter.rb
Overview
This class is abstract.
The purpose of this class is to split the PDF into constituent image files.
Direct Known Subclasses
PagesToJpgsSplitter, PagesToPngsSplitter, PagesToTiffsSplitter
Class Method Summary collapse
Instance Method Summary collapse
- #each {|the| ... } ⇒ Object
-
#initialize(path, tmpdir: Dir.mktmpdir, default_dpi: 400) ⇒ BaseSplitter
constructor
A new instance of BaseSplitter.
-
#invalid_pdf? ⇒ Boolean
private
TODO: put this test somewhere to prevent invalid pdfs from crashing the image service.
Constructor Details
#initialize(path, tmpdir: Dir.mktmpdir, default_dpi: 400) ⇒ BaseSplitter
Returns a new instance of BaseSplitter.
34 35 36 37 38 39 40 |
# File 'lib/iiif_print/split_pdfs/base_splitter.rb', line 34 def initialize(path, tmpdir: Dir.mktmpdir, default_dpi: 400) @baseid = SecureRandom.uuid @pdfpath = path @pdfinfo = IiifPrint::SplitPdfs::PdfImageExtractionService.new(pdfpath) @tmpdir = tmpdir @default_dpi = default_dpi end |
Class Method Details
.call(path) ⇒ Enumerable
Note:
We’re including the ** args to provide method conformity; other services require additional information (such as the FileSet)
26 27 28 |
# File 'lib/iiif_print/split_pdfs/base_splitter.rb', line 26 def self.call(path, **) new(path).to_a end |
Instance Method Details
#each {|the| ... } ⇒ Object
48 49 50 51 52 |
# File 'lib/iiif_print/split_pdfs/base_splitter.rb', line 48 def each entries.each do |e| yield(e) end end |
#invalid_pdf? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
TODO: put this test somewhere to prevent invalid pdfs from crashing the image service.
57 58 59 60 |
# File 'lib/iiif_print/split_pdfs/base_splitter.rb', line 57 def invalid_pdf? return true if pdfinfo.color.include?(nil) || pdfinfo.width.nil? || pdfinfo.height.nil? || pdfinfo.page_count.zero? false end |