I have a ruby app which is happily uploading PDFs to my S3 account and generating a nice little thumbnail preview of the first page of the PDF in the process, in this case, a jpg file.
So far so good.
However, whenever the first page of the PDF contains special characters - in this case the Swedish characters ÅÖÄ - they are simply stripped out of the image and replaced with blanks.
I've tried setting encoding everywhere in the app to UTF-8, but to no avail. Can anyone help me out? Surely I'm not the first person to have spotted that PDF thumbnails are losing special characters, am I?
Here's my code, which works fine in the majority of cases:
class CourseUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :fog
else
storage :file
end
version :web_thumb do
process :thumbnail_pdf
process :resize_to_fit => [150, 150]
process :convert => :jpg
def full_filename (for_file = model.source.file)
super.chomp(File.extname(super)) + '.jpg'
end
end
def thumbnail_pdf
manipulate! do |frame, index|
frame if index.nil?
end
end
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w(pdf)
end
end
And here is a rather sad little thumbnail .jpg image without a Swedish Character "ö" in "för":