- Install gem
wicked-pdf
- Install gems to allow generate pdf from html (using wkhtmltopdf library)
wkhtmltopdf-binary
~ for general
wkhtmltopdf-binary-edge
~ for MacOS and Ubuntu/CentOS
'wkhtmltopdf-binary-aml', git: 'https://github.com/insphire/wkhtmltopdf-binary-aml'
~ for Amazon Linux (use this one)
- Set UTF-8 in HTML
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
# or
<meta charset="UTF-8">
- Install Japanse fonts into AMI
# Download fonts
wget "http://jaist.dl.sourceforge.jp/mix-mplus-ipa/59021/migmix-2p-20130617.zip"
unzip migmix-2p-20130617.zip
# Copy font to new folder '/usr/share/fonts/japanese/TrueType/'
sudo mv -i migmix-2p-20130617/*ttf /usr/share/fonts/japanese/TrueType/
# load new folder
ls /usr/share/fonts/japanese/TrueType/
# output: migmix-2p-bold.ttf migmix-2p-regular.ttf
# Clear font cache
fc-cache -fv
# check new fonts loaded or not
fc-list | grep Mig
# output: MigMix 2P:style=Bold MigMix 2P:style=Regular
- Optional: config in 'wicked_pdf.rb' for load executable file 'wkhtmltopdf'
# base on gem
Gem.bin_path('wkhtmltopdf-binary-edge', 'wkhtmltopdf')
# or
"#{Gem.loaded_specs['wkhtmltopdf-binary'].full_gem_path}/bin/wkhtmltopdf"
# base on file in system
if File.exist?(File.expand_path('~/.rbenv/shims/wkhtmltopdf'))
File.expand_path('~/.rbenv/shims/wkhtmltopdf')
end