diff --git a/lib/libreconv.rb b/lib/libreconv.rb index da81a97..ca589a9 100644 --- a/lib/libreconv.rb +++ b/lib/libreconv.rb @@ -113,7 +113,12 @@ def escaped_source_path # @return [String] def target_filename - File.basename(escaped_source_path, '.*') + '.' + File.basename(@convert_to, ':*') + File.basename(escaped_source_path, '.*') + '.' + target_extname + end + + # @return [String] + def target_extname + @convert_to.split(':')[0] end # @raise [IOError] If soffice headless command line tool not found. diff --git a/spec/fixtures/docx_with_image.docx b/spec/fixtures/docx_with_image.docx new file mode 100755 index 0000000..589b5a2 Binary files /dev/null and b/spec/fixtures/docx_with_image.docx differ diff --git a/spec/libreconv/converter_convert_spec.rb b/spec/libreconv/converter_convert_spec.rb index c3c3c54..4677bd7 100644 --- a/spec/libreconv/converter_convert_spec.rb +++ b/spec/libreconv/converter_convert_spec.rb @@ -10,6 +10,17 @@ end end + it 'converts a file to the specified target html with EmbedImages options' do + create_tmpfile(['', '.html']) do |target_file| + fixture_file = fixture_path('docx_with_image.docx') + described_class.new(fixture_file, target_file, nil, 'html:HTML:EmbedImages').convert + + converted_file = File.read(target_file) + expect(File.size?(target_file)).to be > 0 + expect(converted_file).to include('data:image/png;base64') + end + end + Helpers::FILE_TYPES.each do |type| it "converts a #{type} to pdf" do Dir.mktmpdir do |target_path|