0

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":

enter image description here

Michael Taylor
  • 121
  • 2
  • 6
  • Update. I have now managed to pinpoint the problem to the fonts being used in the original PDFs, which are odd to say the least. is there anyway of adding these special fonts somewhere so that they can be accessed by Carrierwave and MiniMagick? When I use regualr fonts with Roman encoding, the accented charatcers do not fall away at all. – Michael Taylor Oct 20 '15 at 14:54
  • http://stackoverflow.com/questions/24696433/why-font-list-is-empty-for-imagemagick/24701602#24701602 – max Oct 20 '15 at 17:59

0 Answers0