Aspose.Pdf .Net 20.5 TextSegment FontStyle lost when using a breakline

I have trouble using TextSegment with line break and setting font style onto these text segments : when a line break is present, the text segment settings font style is not applied.
How can I use TextSegment with fontstyle and linebreak ?

Below my sample code to reproduce it :

Private Sub TestCellTextWrapped()
    Dim pdf = New Document
    Dim page = pdf.Pages.Add()

    'Dim txtsample = new TextFragment($"Dim{vbcrlf}anche 20/05/2020")
    Dim txtWithOutBreakLine = ConvertInToTextFragment($"Dimanche 20/04/2020")
    Dim txtWithBreakLine = ConvertInToTextFragment($"Dimanche{ControlChars.NewLine}20/04/2020")


    Dim table = New Table()
    page.Paragraphs.Add(table)

    table.ColumnWidths = "150 100"
    table.DefaultCellBorder = New BorderInfo(BorderSide.Box, 0.1)
    Dim row = table.Rows.Add()
    Dim cell = row.Cells.Add()
    cell.Paragraphs.Add(txtWithOutBreakLine)
    cell.Alignment = HorizontalAlignment.Center

    cell = row.Cells.Add()
    cell.Paragraphs.Add(txtWithBreakLine)
    cell.Alignment = HorizontalAlignment.Center

    pdf.Save($"C:\temp\testBreakLineInTextSegmentWithStyle.pdf")
    Process.Start($"C:\temp\testBreakLineInTextSegmentWithStyle.pdf")


End Sub

Private Function ConvertInToTextFragment(phrase As String) As TextFragment
    Dim txtFrag = New TextFragment()
    For Each mot In phrase.Split(" ")
        Dim seg = New TextSegment(mot + " ")
        txtFrag.Segments.Add(seg)
        If mot <> vbCrLf Then
            seg.TextState.FontStyle = FontStyles.Bold
            seg.TextState.ForegroundColor = Aspose.Pdf.Color.DarkRed
            seg.TextState.Font = FontRepository.FindFont("Gisha")
            seg.TextState.FontSize = 10
        Else
            seg.Text = ControlChars.NewLine
        End If

       
    Next

    Return txtFrag
End Function

This sample generate this pdf file : testBreakLineInTextSegmentWithStyle.pdf (11.8 KB)

As you can see, the first cell apply the chosen font style , whereas in the second cell the break line is present but the text has lost the chosen font style.

Thanks for your help.

@Faf78

We have logged an issue as PDFNET-48254 in our issue tracking system and will surely look into its details. We will keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.

@Faf78

We would like to share with you that earlier logged issue has been fixed in Aspose.PDF for .NET 20.7.

Thanks a lot for your work : the new version 20.7 corrects the formatting problem.

Sorry but I have done more tests with 20.7 version, and I’m afraid that there is another problem with formatting TextSegment using new line ; below my sample code :

 Private Sub TestCellTextFormattingWithNewLine()
        Dim pdf = New Document
        Dim page = pdf.Pages.Add()

        Dim txt0 = ConvertInToTextFragment($"Valserine", aspose.Pdf.Color.DarkRed, Text.FontStyles.Bold, "Gisha")
        dim txt1 = ConvertInToTextFragment($" : inférieur à 5.", aspose.Pdf.Color.Blue, Text.FontStyles.Regular, "Gisha")
        For Each seg In txt1.Segments
            txt0.Segments.Add(seg)
        Next

        txt0.Segments.Add(New TextSegment(ControlChars.NewLine))
        
        dim txtSeg = new TextSegment("Other word")
        txtSeg.TextState.Font = FontRepository.FindFont("Gisha")
        txtSeg.TextState.ForegroundColor = Color.Blue
        txtSeg.TextState.FontSize = 10
        txt0.Segments.Add(txtSeg)

        Dim table = New Table()
        page.Paragraphs.Add(table)

        table.ColumnWidths = "300"
        table.DefaultCellBorder = New BorderInfo(BorderSide.Box, 0.1)
        Dim row = table.Rows.Add()
        Dim cell = row.Cells.Add()
        cell.Paragraphs.Add(txt0)
        cell.Alignment = Aspose.Pdf.HorizontalAlignment.Left

        pdf.Save($"C:\temp\testNewLineInTextSegmentWithFormatting.pdf")
        Process.Start($"C:\temp\testNewLineInTextSegmentWithFormatting.pdf")
    End Sub

    Private Function ConvertInToTextFragment(phrase As String, couleur As Aspose.Pdf.Color, fontstyle As Facades.FontStyle, fontName As String) As TextFragment
        Dim txtFrag = New TextFragment()
        For Each mot In phrase.Split(" ")
            Dim seg = New TextSegment(mot & " ")            
            If mot <> vbCrLf Then
                seg.TextState.FontStyle = fontstyle
                seg.TextState.ForegroundColor = couleur
                seg.TextState.Font = FontRepository.FindFont(fontName)
                seg.TextState.FontSize = 10
            Else
                seg.Text = ControlChars.NewLine
            End If

            txtFrag.Segments.Add(seg)
        Next

        Return txtFrag
    End Function

Result pdf file : testNewLineInTextSegmentWithFormatting.pdf (37.0 KB)

As you can see the first line has lost its formatting…
If you comment the line “txt0.Segments.Add(New TextSegment(ControlChars.NewLine))”, the formatting is good (but no newLine).

Could you investigate or give me a workaround ?
Thanks in advance.

Sincerly,
Fabien

@Faf78

We were able to reproduce the issue in our environment and logged it as PDFNET-48578 in our issue tracking system. We will further look into detail of this case and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hello,

Have you got some solution about this problem ?

Thanks in advance.

@Faf78

Sadly, the earlier logged ticket is not yet resolved due to other issues logged prior to it. We will surely inform you as soon as we make some significant progress towards its resolution. Please be patient and spare us some time.

We are sorry for your inconvenience.

Hello,

I still haven’t heard from PDFNET-48578 and my customer is getting impatient. Can I have a target date to fix this bug ?

Tanks a lot.
Best regards.

@Faf78

The earlier logged ticket is currently under the phase of investigation and as soon as analysis is done, we will share further updates with you regarding its fix ETA or resolution. We greatly appreciate your patience and cooperation in this matter. Please give us some time.

We apologize for your inconvenience.

This ticket has been opened more than a year ago, we checked with the latest version and the bug is still there. We are customer for more thant 10 years now … we are upset to see nothing is really done about it !

@dvpsoftware.cnr.tm.f

Please accept our humble apology for the inconvenience and delay you have been facing. We really regret to inform you that the issue could not be resolved yet. However, we have recorded your concerns and have raised the issue priority. We will surely complete its analysis and let you know once we have definite news about its fix. We highly appreciate your patience and comprehension in this regard.

We again apologize for your inconvenience.

Could it get fixed using paid support ?

@dvpsoftware.cnr.tm.f

Sure. The paid/priority support option has been give so that showstopper issues can be reported there and fixed on urgent basis. The issue priority will get escalated as soon as you create a post in paid support with the reference to ticket IDs.

The issues you have found earlier (filed as PDFNET-48578) have been fixed in Aspose.PDF for .NET 22.8.