Class: IiifPrint::SplitPdfs::BaseSplitter Abstract
- Inherits:
-
Object
- Object
- IiifPrint::SplitPdfs::BaseSplitter
- Includes:
- Enumerable
- Defined in:
- lib/iiif_print/split_pdfs/base_splitter.rb
Overview
The purpose of this class is to split the PDF into constituent image files.
Direct Known Subclasses
PagesToJpgsSplitter, PagesToPngsSplitter, PagesToTiffsSplitter
Class Method Summary collapse
- .call(path) ⇒ Enumerable
-
.never_split_pdfs? ⇒ Boolean
Added to allow for fine-tuning of splitting decision such as tenant-based omission.
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.
45 46 47 48 49 50 51 |
# File 'lib/iiif_print/split_pdfs/base_splitter.rb', line 45 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
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 |
.never_split_pdfs? ⇒ Boolean
Added to allow for fine-tuning of splitting decision such as tenant-based omission
37 38 39 |
# File 'lib/iiif_print/split_pdfs/base_splitter.rb', line 37 def self.never_split_pdfs? false end |
Instance Method Details
#each {|the| ... } ⇒ Object
59 60 61 62 63 |
# File 'lib/iiif_print/split_pdfs/base_splitter.rb', line 59 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.
68 69 70 71 |
# File 'lib/iiif_print/split_pdfs/base_splitter.rb', line 68 def invalid_pdf? return true if pdfinfo.color.include?(nil) || pdfinfo.width.nil? || pdfinfo.height.nil? || pdfinfo.page_count.zero? false end |