We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Adjust line height in TextFragment in Aspose.PDF for .NET - more spaces are added

Hello,
I am reading data from a text file and creating a PDF. There is an instance where I need to adjust the line height of one row in the pdf. Below is the code I am using. It doesn’t seem to work. It either makes the disappear or adds more spacing instead of less. We are trying to adjust the line height smaller.
Any ideas? In the code below where I put the ? mark is where I am editing…
’ *************************************************************************************
Dim document As Document = New Document()
document.Pages.Add()
Dim data As System.IO.StreamReader = New StreamReader(txtPath)
Dim nextLine As String = “”
Dim page As Page = document.Pages(1)

Dim i As Integer = 0
Dim priorLine As String = ""
Dim pageNum As Integer = 1

While (data.EndOfStream = False)
            i += 1
            priorLine = nextLine
            If i = 1 Then
While nextLine = ""
                    nextLine = data.ReadLine
                End While
Else
                nextLine = data.ReadLine
            End If

Dim text As TextFragment = New TextFragment(nextLine)

            text.TextState.Font = FontRepository.FindFont("Courier")
            text.TextState.FontSize = Fontsize
            ' TRYING TO DO THE LINE HEIGHT HERE
            text.TextState.Linespacing = ?

            page.Paragraphs.Add(text)

        End While

        document.Save(pdfPath) ' & "\" & "test_out.pdf")

@LeeWheeler,

Can you please share source files along with generated result so that we may further investigate to help you out.

The source file is just a txt file that we read in… nothing special about it. For some lines that we read in, we need to adjust the line height. Will the “LineSpacing” property allow for the expanding and contracting of the line that the text is displayed in the pdf or should I be using a different?

Thank you for your help.

@LeeWheeler,

I like to inform that it is necessary to share source files with so that we may investigate further to help you out.

Here is the source file that we read in. The lines that begin with a “+”, we need to remove the white space over the line so it appears that the line above it is underlined.

STATE OPERATIONS

GOVERNOR, EXECUTIVE OFFICE
PGM: GENERAL OFFICE
EXECUTIVE DIR/SUPPORT SVCS
+__________________________
GOV OPERATIONS/SUPPORT
EXEC LEADERSHIP/SUPPRT SVC
+__________________________
ESTIMATED EXPENDITURES
ESTIMATED EXPENDITURES - OPERATIONS
SALARIES AND BENEFITS

@LeeWheeler,

Thanks for contacting support.

I have observed your issue and like to inform that I have created investigation ticket with ID PDFNET-47614 in our issue tracking system to investigate and resolve this issue as soon possible.

Thank you! I appreciate the assistance with this issue.:hearts: