After some investigation (code below), it appears that the Text Ascent (and to a smaller extent, Descent) values have changed for a number of fonts. Is this an intentional change? Is there some other way we could/should be calculating line height, or some simple way we can account for the change so that v10 PDFs look the same as v9 PDFs?
While the changes appear to be constant for each font (i.e. Arial is always increased by 1.2431), I'd rather not put in some kind of hack to adjust the sizes as that will be a maintenance problem going forward.
Public Shared Function GetBaselineOffsetToUse(quickPDF_ As PDFLibrary) As Decimal
Dim tmpAscent As Decimal = CDec(quickPDF_.GetTextAscent())
Dim tmpDescent As Decimal = CDec(quickPDF_.GetTextDescent())
Return tmpAscent + Math.Abs(tmpDescent)
End Function
'***************************************************************************
'***************************************************************************
Public Shared Function GetTextHeightToUse(quickPDF_ As PDFLibrary) As Decimal
Dim tmpDistToBaseline As Decimal = GetBaselineOffsetToUse(quickPDF_)
Dim tmpHeight As Decimal = CDec(quickPDF_.GetTextHeight())
Dim tmpDescent As Decimal = Math.Abs(CDec(quickPDF_.GetTextDescent()))
Dim tmpSize As Decimal = CDec(quickPDF_.GetTextSize())
Return tmpDistToBaseline + tmpDescent 'tmpAscentAndDescent ' tmpHeight
End Function
Dim quickPDF914 As New DebenuPDFLibraryAX0914.PDFLibrary
Dim quickPDF1013 As New DebenuPDFLibraryAX1013.PDFLibrary
quickPDF914.SetMeasurementUnits(2) ''Inches
quickPDF914.SetOrigin(1) '' Top left
quickPDF914.SetPageDimensions(8.5D, 11D)
quickPDF1013.SetMeasurementUnits(2) ''Inches
quickPDF1013.SetOrigin(1) '' Top left
quickPDF1013.SetPageDimensions(8.5D, 11D)
TestFont(quickPDF914, quickPDF1013, "Arial", 12)
TestFont(quickPDF914, quickPDF1013, "Arial", 18)
TestFont(quickPDF914, quickPDF1013, "Arial", 24)
TestFont(quickPDF914, quickPDF1013, "Arial", 36)
Private Sub TestFont(quickPDF914 As DebenuPDFLibraryAX0914.PDFLibrary, quickPDF1013 As DebenuPDFLibraryAX1013.PDFLibrary, fontName As String, fontSize As Decimal)
Console.WriteLine("Font: {0} {1}pt", fontName, fontSize)
quickPDF914.SelectFont(quickPDF914.AddTrueTypeFont(fontName, 0))
quickPDF914.SetTextSize(fontSize)
Dim tmpHeight As Decimal = CDec(quickPDF914.GetTextHeight())
Dim tmpAscent As Decimal = Math.Abs(CDec(quickPDF914.GetTextAscent()))
Dim tmpOldAscent As Decimal = tmpAscent
Dim tmpDescent As Decimal = Math.Abs(CDec(quickPDF914.GetTextDescent()))
Dim tmpSize As Decimal = CDec(quickPDF914.GetTextSize())
Dim tmpTextBound As Decimal = CDec(quickPDF914.GetTextBound(2)) ' 2 = top
Console.WriteLine("Old font height: {0:#0.000}, ascent: {1:#0.000}, descent: {2:#0.000}, size: {3:#0.000}, top: {4:#0.000}", tmpHeight, tmpAscent, tmpDescent, tmpSize, tmpTextBound)
quickPDF1013.SelectFont(quickPDF1013.AddTrueTypeFont(fontName, 0))
quickPDF1013.SetTextSize(fontSize)
tmpHeight = CDec(quickPDF1013.GetTextHeight())
tmpAscent = Math.Abs(CDec(quickPDF1013.GetTextAscent()))
tmpDescent = Math.Abs(CDec(quickPDF1013.GetTextDescent()))
tmpSize = CDec(quickPDF1013.GetTextSize())
tmpTextBound = CDec(quickPDF1013.GetTextBound(2)) ' 2 = top
Console.WriteLine("New font height: {0:#0.000}, ascent: {1:#0.000}, descent: {2:#0.000}, size: {3:#0.000}, top: {4:#0.000}", tmpHeight, tmpAscent, tmpDescent, tmpSize, tmpTextBound)
Console.WriteLine("New font ascent / Old font ascent: {0:#0.0000}", tmpAscent / tmpOldAscent)
End Sub