aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2015-02-12 17:29:20 +0000
committerLouise Crow <louise.crow@gmail.com>2015-05-07 16:17:30 +0100
commita5911f4e36de4bb94689d92aece4b0dc3bd649d7 (patch)
treee74b1c046755d7218525e0c1e8fb0ca2f7e03c03
parent6e6b75ff6b2853c672aaecbbcbc2ddc19d81e738 (diff)
Set binary mode to false in call to pdftohtml
We want the HTML to be encoding in the default encoding so that it can be combined with other strings.
-rw-r--r--lib/attachment_to_html/adapters/pdf.rb3
-rw-r--r--spec/lib/attachment_to_html/adapters/pdf_spec.rb17
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/attachment_to_html/adapters/pdf.rb b/lib/attachment_to_html/adapters/pdf.rb
index b91958c52..3183d1fd0 100644
--- a/lib/attachment_to_html/adapters/pdf.rb
+++ b/lib/attachment_to_html/adapters/pdf.rb
@@ -73,11 +73,10 @@ module AttachmentToHTML
html = AlaveteliExternalCommand.run("pdftohtml",
"-nodrm", "-zoom", "1.0", "-stdout", "-enc", "UTF-8",
- "-noframes", tempfile.path, :timeout => 30
+ "-noframes", tempfile.path, :timeout => 30, :binary_output => false
)
cleanup_tempfile(tempfile)
-
html
end
end
diff --git a/spec/lib/attachment_to_html/adapters/pdf_spec.rb b/spec/lib/attachment_to_html/adapters/pdf_spec.rb
index da79b2de0..f1ae4695c 100644
--- a/spec/lib/attachment_to_html/adapters/pdf_spec.rb
+++ b/spec/lib/attachment_to_html/adapters/pdf_spec.rb
@@ -15,7 +15,7 @@ describe AttachmentToHTML::Adapters::PDF do
adapter = AttachmentToHTML::Adapters::PDF.new(attachment, :tmpdir => '/tmp')
adapter.tmpdir.should == '/tmp'
end
-
+
end
describe :title do
@@ -23,7 +23,14 @@ describe AttachmentToHTML::Adapters::PDF do
it 'uses the attachment filename for the title' do
adapter.title.should == attachment.display_filename
end
-
+
+ it 'returns the title encoded as UTF-8' do
+ if RUBY_VERSION.to_f >= 1.9
+ adapter.title.encoding.should == Encoding.find('UTF-8')
+ end
+ end
+
+
end
describe :body do
@@ -38,6 +45,12 @@ describe AttachmentToHTML::Adapters::PDF do
adapter.body
end
+ it 'returns the body encoded as UTF-8' do
+ if RUBY_VERSION.to_f >= 1.9
+ adapter.body.encoding.should == Encoding.find('UTF-8')
+ end
+ end
+
end