SVG to PDF encoding error #1239
-
Greetings, This is an issue in writing PDF from SVG using Trying to render a simple SVG as PDF with non-ASCII character gives an error: This is the SVG string: <?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<text x="100" y="100">
木
</text>
</svg> And this is the script: require 'victor'
require 'prawn-svg'
require 'prawn'
svgout = Victor::SVG.new
svgout.build { text "木", x: 100, y: 100 }
Prawn::Document.generate("svg.pdf") do
font "#{ENV["HOME"]}/Library/Fonts/gkai00mp.ttf"
text "山"
svg svgout.render
end The font works properly: without Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 5 replies
-
Could you please share what the call to Like this, maybe: Prawn::Document.generate("svg.pdf") do
font "#{ENV["HOME"]}/Library/Fonts/gkai00mp.ttf"
text "山"
pp svg svgout.render
end |
Beta Was this translation helpful? Give feedback.
-
Thank you for the response. This is the output.
|
Beta Was this translation helpful? Give feedback.
-
My mistake. I typed
|
Beta Was this translation helpful? Give feedback.
-
After a bit of poking, I think that the problem is that you haven't declared a font in your SVG, so it's falling back to the default PDF fonts, which are Windows-1252-only. It looks like you might need to add your font separately to |
Beta Was this translation helpful? Give feedback.
-
Thank you for your suggestion. I found that either
|
Beta Was this translation helpful? Give feedback.
Thank you for your suggestion. I found that either
style="font-family: ...
or"font-family: ..."
works. I used the latter because of the definition. But to work it needsfont
as the name not the path andfont_families
to be added.