Tab escape character in TextSegment

Hi,


What is the tab escape character in a TextSegment? I tried with \t and it creates one space only. My understanding is it should create more than one space.

Please advise.

Thanks,
Mary

Hi Mary,


Thanks for your inquiry. I have noticed that “\t” escape character adds one space in TextSegment. So after initial investigation, I have logged a ticket PDFJAVA-35963 in our issue tracking system for further investigation and resolution. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience.

Best Regards,

Hi Mary,

Thanks for your patience. Please use following code snippet to add tab escape character. Please note that the length of the tab can be set within the method add (ts.add(100)).

TabStops ts = new TabStops();
TabStop ts1 = ts.Add(100);
ts1.AlignmentType = TabAlignmentType.Right;
ts1.LeaderType = TabLeaderType.None;

Document doc = new Document();
Page page = doc.Pages.Add();
TextFragment textFragment = new TextFragment("Normal black text ", ts);
TextSegment seg1 = new TextSegment("Bold black text" + "#$TAB" + "test ");
seg1.TextState.FontStyle = FontStyles.Bold;
TextSegment seg2 = new TextSegment("Red text");
seg2.TextState.ForegroundColor = com.aspose.pdf.Color.Red;

textFragment.Segments.Add(seg1);
textFragment.Segments.Add(seg2);

page.Paragraphs.Add(textFragment);

doc.Save(myDir + "Test.pdf");

Please feel free to contact us for any further assistance.

Best Regards,