Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Different text ascent size in v10 from v9?
  FAQ FAQ  Forum Search   Register Register  Login Login

Different text ascent size in v10 from v9?

 Post Reply Post Reply
Author
Message
eric_moraware View Drop Down
Beginner
Beginner


Joined: 02 Apr 14
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote eric_moraware Quote  Post ReplyReply Direct Link To This Post Topic: Different text ascent size in v10 from v9?
    Posted: 02 Apr 14 at 6:14PM
Hi, we just updated from version 9.14 to 10.13 and we're seeing changed results when printing PDFs. Specifically, the whitespace between lines has increased in 10.13 in a way that is making our users (who have spent a lot of time making forms fit exactly one page) very unhappy.

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.

Here's how we're calculating our line heights:

    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

And here's my sample code demonstrating that the font ascent/descent changed:

        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

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store