Class: DocPDF::Adapters::Converters::Fallback

Inherits:
Base
  • Object
show all
Defined in:
lib/docpdf/adapters/converters/fallback.rb

Overview

Fallback converter for unrecognized mime types. Tries three strategies in order:

  1. If the source filename has a known image extension, detect its mime type and delegate to the appropriate image converter.
  2. Attempt conversion via LibreOffice (soffice), which can handle many formats not explicitly registered.
  3. If soffice is unavailable or fails, return the raw data unchanged.

Constant Summary collapse

IMAGE_EXTENSIONS =
%w[.heic .heif .webp .jpg .jpeg .png].freeze

Constants inherited from Base

Base::MIME_TYPES

Class Method Summary collapse

Class Method Details

.convert(data, source_filename) ⇒ Object



19
20
21
22
23
# File 'lib/docpdf/adapters/converters/fallback.rb', line 19

def convert(data, source_filename)
  convert_by_extension(data, source_filename) ||
    convert_with_soffice(data, source_filename) ||
    data
end