Text with TabStops is not working if line is broken

Hello Aspose,

if a line containing tabstops is breaking at line end the following #$TAB are not replaced anymore.
grafik.png (16.6 KB)

Further the set font is ignored, which I can observe if I set it in the first line (TextFragment header).
If I reduce the line length, the TabStops seems to work, but the text is shifted left which is not the indented behavior of a TabStop. The next matching TabStop behind the former Segment should be choosen.

grafik.png (5.8 KB)

Is there a workaround?

Regards
Gerd

        private static string TabStopTest(Page page)
        {

            TabStops tss = new Aspose.Pdf.Text.TabStops();
            var ts = tss.Add(27 );
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts = tss.Add(54 );
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts = tss.Add(81 );
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(108);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(135);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(162);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(189);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(216);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(243);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(270);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(297);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(324);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(351);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(378);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(405);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;
            ts= tss.Add(432);
            ts.AlignmentType = TabAlignmentType.Right;
            ts.LeaderType = TabLeaderType.None;

            TextFragment header = new TextFragment("This is a example of forming table with TAB stops");
            TextFragment text = new TextFragment(tss);
            text.Segments.Add(new TextSegment("the#$TABpseudo table#$TABwith monospace text:#$TAB 3the#$TABtable#$TAB#$TABwith     text:#$TAB#$TAB#$TAB 5#$TABpseudo table#$TABwith monospace text:#$TAB 3#$TAB#$TAB#$TABtable#$TABwith text:#$TAB#$TAB 6\"") { TextState = { Font = FontRepository.FindFont("Courier New")}});

            page.Paragraphs.Add(header);
            page.Paragraphs.Add(text);

            return Path.Combine(myDataDir, "TabStopTest.pdf");
        }

        public static void Main()
        {
            Document doc = new Document();
            
            Page page = doc.Pages.Add();

            var file = TabStopTest(page);
            

            if (File.Exists(file)) { File.Delete(file); }
            doc.Save(file);
            Process.Start(file);
        }

@Gerd
Let me investigate a bit this issue, I’ll anwser you shortly

@Gerd
I’ve investiagated a bit
short_text_with_alignment_left.png (6.2 KB)

In case with short text you can somehow workaround the issue by changing alignment to Left, the text seems normal if you work with shorter
I tried if something like following will work:

Document doc = new Document();
Page page = doc.Pages.Add();
TabStops tss = new Aspose.Pdf.Text.TabStops();
var ts = tss.Add(27);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(54);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(81);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(108);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(135);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(162);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(189);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(216);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(243);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(270);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(297);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(324);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(351);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(378);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(405);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
ts = tss.Add(432);
ts.AlignmentType = TabAlignmentType.Left;
ts.LeaderType = TabLeaderType.None;
TextFragment header = new TextFragment("This is a example of forming table with TAB stops");
TextFragment text = new TextFragment(tss);
var fullTxt = "the#$TABpseudo table#$TABwith monospace text:#$TAB 3the#$TABtable#$TAB#$TABwith     text:#$TAB#$TAB#$TAB 5#$TABpseudo table#$TABwith monospace text:#$TAB 3#$TAB#$TAB#$TABtable#$TABwith text:#$TAB#$TAB 6\"";
var normalTxt = "the#$TABpseudo table#$TABwith monospace text:#$TAB 3";
while (normalTxt.Length < fullTxt.Length)
{
    text.Segments.Add(new TextSegment(normalTxt) { TextState = { Font = FontRepository.FindFont("Courier New") } });
    fullTxt = fullTxt.Substring(normalTxt.Length);
    normalTxt = fullTxt.Substring(0, normalTxt.Length< fullTxt.Length? normalTxt.Length: fullTxt.Length);
}
page.Paragraphs.Add(header);
page.Paragraphs.Add(text);
doc.Save(OutputFolder + "TabStopTest.pdf");

It seems better but it doesn’t resolve the actual problem
split_version.png (10.5 KB)
However, as i was said, there were some changes in coming version where at least there’s improvements on this case, your current code snippet will result in this:
develop_24_11_version.png (8.1 KB)
so maybe with this two approaches combined it can be resolved
I’ll add task anyway as right alignmnent doesn’t seem to work correctly

@Gerd
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-58562

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.