Porting from itextsharp to itext 7 - Why is itext7 giving me a slightly larger value for the Height of text for the same PDF?
user44821 Published in September 19, 2018, 9:08 am
I am in the process of porting my code to itext 7. While running some unit tests, I noticed that there was a difference of about 2 pixels or more in the height of text elements when I compared the same PDF with itextsharp and itext7.
The difference becomes progressively higher with increasing text size. I have a custom strategy class with the following code snippet. The variables width and height shows how I am arriving at the dimensions.
public void RenderText(TextRenderInfo renderInfo)
var baseline = renderInfo.GetBaseline();
var ptStartBaseline = baseline.GetStartPoint();
var ptEndBaseline = baseline.GetEndPoint();
var bottomLeft = renderInfo.GetDescentLine().GetStartPoint();
var topRight = renderInfo.GetAscentLine().GetEndPoint();
float xbotleft = bottomLeft.Get(iText.Kernel.Geom.Vector.I1);
float ybotleft = bottomLeft.Get(iText.Kernel.Geom.Vector.I2);
float xtopright = topRight.Get(iText.Kernel.Geom.Vector.I1);
float ytopright = topRight.Get(iText.Kernel.Geom.Vector.I2);
float width = xtopright - xbotleft;
float height = ytopright - ybotleft;
Where am I going wrong?
.net itext itext7
share|improve this question
edited Apr 17 at 11:59
asked Apr 17 at 11:20
Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.
Browse other questions tagged .net itext itext7 or ask your own question.