Wicked_pdf and utf8 symbol
Asked Answered
H

3

8

In my generated pdf I get this

0,00 €

instead of

0,00 €

Application.html.erb

  <meta charset="utf-8">
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />

show.html.erb

<%=number_to_currency item.total%>
Hysterectomy answered 22/4, 2014 at 21:58 Comment(0)
H
25
respond_to do |format|
  format.html { render template: 'invoices/show' }
  format.pdf  do
    render pdf: 'invoices/show',
           template: 'invoices/show', 
           formats: :HTML, 
           encoding: 'utf8'
  end
end
Hysterectomy answered 23/4, 2014 at 11:49 Comment(1)
You can also put same setting encoding: 'utf8' into your initializers\wicked_pdf config fileVolney
H
1

Still i can see the special characters in the PDF. Below is my code

pdf = WickedPdf.new.pdf_from_string(page_html,:page_size => "A3") 

  send_data(pdf, 
    :filename => "my_pdf_name.pdf", 
    :formats => 'HTML', 
    :encoding => 'utf8',
    :disposition => 'attachment') 
  end
Hanna answered 14/4, 2021 at 11:29 Comment(3)
I use this format.pdf do render pdf: "invoice", layout: 'layouts/metronic/blank.pdf', template: 'invoices/show', formats: :html, encoding: 'utf8' endHysterectomy
Check for valid HTML doctypeHysterectomy
Yes, I am using the format as HTML and utf8 as encoding. Can you just tell, what's wrong with the above code snippetHanna
H
0

config/initializers/wicked_pdf.rb

  WickedPdf.config = {
    encoding: 'utf8'
  }
Henka answered 13/1, 2023 at 22:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.