Forum How do I...?

SVG text positioning problem

jorma
I'm trying to create a PDF out of this HTML page the alignment of the text in the SVG doesn't come out right as you can see in this PDF(generated with Prince v9r4).

Any ideas?
mikeday
Which text? Can you post a screenshot showing the difference? It looks quite similar in Firefox.
jorma
Have a look in Chrome, the numbers in the boxes are aligned in the center. I used alignment-baseline: central; on the text element.
  1. Screen Shot 2014-02-15 at 10.28.43.png737.0 kB
mikeday
Unfortunately Prince does not currently support the alignment-baseline property. :(
jorma
Ah... that explains it then. Thank you! To your knowledge, is there another way to vertically center text in relation to another element?

Oh and sorry for posting in this forum category... could you move the discussion to a more appropriate category?
mikeday
Not that I can recall; the text-anchor property is only for horizontal alignment.
steven_noble
Any word on when PrinceXML will start supporting alignment-baseline when rendering SVG? This is important to me. Thanks.
mikeday
We will investigate and see if we can support this in a future release.
mikeday
May I ask what is your major requirement for alignment-baseline? We have found that it does not seem to be supported by many SVG renderers, and there are other vertical alignment properties such as vertical-align and dominant-baseline.
steven_noble
To vertically position text in the middle of graphics. In the mean time I've found I fake this by aligning the graphics to the top of the point equal to half way down the graphic plus half the font's height, which works but makes my code very hard to alter/maintain.
mikeday
We have now added support for the SVG dominant-baseline and baseline-shift properties, these can be used for vertical centering and may be more portable than alignment-baseline, which doesn't work in most browsers.

If you would like to try the new properties, just let me know which operating system you are running Prince on.
steven_noble
Thanks mikeday. That's great. I use Prince on Docraptor so I guess I'll have to wait for you to push a new GM that they support.
steven_noble
Hi mikeday -- do you mind advising which version of PrinceXML you added this to? I think DocRaptor supports v9 only but I've pinged them to check.
steven_noble
Actually DocRaptor just confirmed they support v10, even though their docs only mentioned v9, so all good
mikeday
Actually these new SVG properties are only supported in Prince latest builds, not Prince 10.