Forum Bugs

SVG not rendering

facboy
I'm trying to render some SVG and it doesn't show up at all in the PDF. It's SVG that's been generated by a HighStock chart. I've successfully rendered other Highcharts output so I'm a bit mystified by this.

Prince doesn't log any errors.
  1. some.svg30.4 kB
    highstock svg
mikeday
This appears to be a width/height/viewBox issue scaling the SVG too small, which we have corrected for the next release of Prince; see the attached PDF files below. A quick workaround is to add viewBox="0 0 600 400" to the root SVG element.
  1. new.pdf10.0 kB
    new output for next release
  2. old.pdf10.0 kB
    current output from Prince 8.1

Edited by mikeday

facboy
works now :). btw it's 'viewBox' - it's case-sensitive.
mikeday
Thanks, edited. :)
facboy
btw, does anyone know why enabling javascript on eg a highcharts page still doesn't result in the chart being rendered? prince doesn't log any JS errors etc, it just doesn't produce anything. animation etc are turned off.
mikeday
HighCharts uses some JavaScript DOM features that we haven't supported in Prince yet, and I think it catches any exceptions internally, which is why no errors show up in the log. We're working on this, but it's a big job. In the meantime, the SVG export is the easiest workaround.
facboy
yes, it seems so. possibly a dumb question, is there any neat way to convert pdf mm/cm sizes into pixels, which seems to be all that highcharts understands?
mikeday
Pixels in SVG are generally 96dpi, the same as in CSS, but Prince has treated SVG pixels slightly inconsistently, so they might be 72dpi in the version you are using. The next release of Prince will treat SVG and CSS pixel units more consistently.
mikeday
Prince 9 is now available, with more consistent treatment of pixel units in SVG and a fix for the width/height viewBox issue.