I'm using gem 'pdfkit'
and gem 'wkhtmltopdf-binary'
to generate the invoices on the Ruby on Rails app. I've a erb file, I'm rendering it as follow:
kit = PDFKit.new(ActionController::Base.new.render_to_string('billing/invoice_pdf', layout: nil, locals: { invoice: invoice_data }), pdf_option)
file = kit.to_file("#{Rails.root}/tmp/#{@invoice.id}_#{@invoice.remote_id}.pdf")
@invoice.document = Document.create(file: file)
and the pdf_option
is
def pdf_option
{
disable_smart_shrinking: false,
page_size: 'A4',
margin_top: '0',
margin_right: '0',
margin_bottom: '0',
margin_left: '0',
encoding: 'UTF-8'
}
end
The generated pdf looks good on local machine, however it gets weird on the production server.
This one is the local machine pdf
and this one is from production
Any idea? what could be the wrong? Thank you