TabStop and TabLeaderType does not honor Font

Aspose.Pdf 10.9

The below code demonstrates that the leader character does not change with the assigned font.

Our workaround is using System.Drawing to estimate the number of leader characters and explicitly create them.

No rush, just wanted to let you know.

Steve

using Aspose.Pdf.Generator;
using System.IO;

namespace TestAspose
{
class Program
{
static void Main(string[] args)
{
const float columnWidth = 300;

Table table = new Table
{
DefaultCellTextInfo = new TextInfo { FontName = "Times", FontSize = 12, Alignment = AlignmentType.Left },
ColumnWidths = columnWidth.ToString()
};
Text cellText = table
.Rows.Add()
.Cells.Add("left\tright")
.Paragraphs[0] as Text;
cellText.TabStops = new TabStops();
TabStop rightTabStop = cellText.TabStops.Add(columnWidth, Aspose.Pdf.Generator.TabLeaderType.Dot);
rightTabStop.AlignmentType = Aspose.Pdf.Generator.TabAlignmentType.Right;

using (FileStream documentStream = new FileStream("c:/leader.pdf", FileMode.Create))
{
Pdf doc = new Pdf(documentStream);
Section section = doc.Sections.Add();
section.AddParagraph(table);
doc.Close();
}
}
}
}

Hi Steve,


Thanks for your inquiry. I have tested your shared code in Aspose.Pdf for .NET 11.0.0 and unable to notice the issue, Text font in resultant PDF is Times New Roman with 12 font size. Please find attached sample output. Please share your sample output with some more details, so we will look into it and guide you accordingly.

Furthermore. please note it is recommended to use new generator instead old generator(Apose.Pdf.Generator), as new generator is more improved and efficient. Moreover old generator will be obsolete in near future. Please check following code snippet for TabStop.

Document pdfdocument = new Document();<o:p></o:p>

Aspose.Pdf.Page page = pdfdocument.Pages.Add();

Aspose.Pdf.Text.TabStops ts = new Aspose.Pdf.Text.TabStops();

Aspose.Pdf.Text.TabStop ts1 = ts.Add(100);

ts1.AlignmentType = TabAlignmentType.Right;

ts1.LeaderType = TabLeaderType.Solid;

Aspose.Pdf.Text.TabStop ts2 = ts.Add(200);

ts2.AlignmentType = TabAlignmentType.Center;

ts2.LeaderType = TabLeaderType.Dash;

Aspose.Pdf.Text.TabStop ts3 = ts.Add(300);

ts3.AlignmentType = TabAlignmentType.Left;

ts3.LeaderType = TabLeaderType.Dot;

TextFragment header = new TextFragment("This is a example of forming table with TAB stops", ts);

TextFragment text0 = new TextFragment("#$TABHead1 #$TABHead2 #$TABHead3", ts);

text0.TextState.FontStyle = FontStyles.Bold;

TextFragment text1 = new TextFragment("#$TABdata11 #$TABdata12 #$TABdata13", ts);

TextFragment text2 = new TextFragment("#$TABdata21 ", ts);

text2.Segments.Add(new TextSegment("#$TAB"));

text2.Segments.Add(new TextSegment("data22 "));

text2.Segments.Add(new TextSegment("#$TAB"));

text2.Segments.Add(new TextSegment("data23"));

page.Paragraphs.Add(header);

page.Paragraphs.Add(text0);

page.Paragraphs.Add(text1);

page.Paragraphs.Add(text2);

pdfdocument.Save(myDir+"TextStop_DOM.Pdf");

We are sorry for the inconvenience caused.


Best Regards,