SVG
SVG copied to clipboard
svgdoc.Ppi not respected
According to #313 one can set Ppi after creating an SvgDocument.
SvgDocument svgDoc = SvgDocument.Open(xmlDoc);
svgDoc.Ppi = (int)e.Graphics.DpiX;
...
svgDoc.Height = new SvgUnit(SvgUnitType.Millimeter, 20);
float h = (int) svgDoc.Height;
In my tests the printer device context DpiX value is 600 and this is definitely assigned to Ppi.
However, the value returned into h is 75.6.
The correct result is 20 / 25.4 * 600 = 472.441
Working backward from the actual result 20 / 25.4 * dpi = 75.6 w have dpi = 75 / (20 / 25.4) = 96 which is the default dpi.
On this basis I assert that Ppi is not respected.
Rummaging, implicit conversion does this .ToDeviceValue(null, UnitRenderingType.Other, null) and because owner is not supplied ppi is obtained from SvgDocument.PointsPerInch which matches the observed behaviour.
What is the recommended way to do this kind of conversion?
Explicit conversion with a supplied owner also fails. I found the bug and corrected it, at some point I will do a PR
@PeterWone - are you still planning to make the PR?
I admit I forgot about it. I will do something about it after work now that you have reminded me.
Thanks :)
@PeterWone Any updates on the PR? If not please show your bug fix here would be helpful to others. Thanks.
Does anyone has a work around this issue?