Free Support Forum - aspose.com

Tab alignment fails when setting fontname

Please see attached document which was generated with code below using dll version 3.6.1.11.

On each line first tab aligns Right, other tabs align Left (=default).<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

When using default fontname all four lines align equally.

When setting fontname to “Arial”, on the last two lines the string “<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />300” don’t align to the next tab.

Is it a bug?

Arjen.

protected void SetTabStops(Aspose.Pdf.Text txt)

{

txt.TabStops = new TabStops();

txt.TabStops.Add(150);

txt.TabStops.Add(170);

txt.TabStops.Add(300);

txt.TabStops[0].AlignmentType = TabAlignmentType.Right;

}

protected void btnTestPath_Click(object sender, EventArgs e)

{

const string csTab = "#$TAB";

Pdf pdf1 = new Aspose.Pdf.Pdf();

Section sec1 = pdf1.Sections.Add();

Aspose.Pdf.Text txt1 = new Text("x" + csTab + "x" + csTab + "x");

SetTabStops(txt1);

sec1.Paragraphs.Add(txt1);

// font = default

Aspose.Pdf.Text txt2 = new Text("Test OK" + csTab + ":" + csTab + "300");

SetTabStops(txt2);

sec1.Paragraphs.Add(txt2);

Aspose.Pdf.Text txt6 = new Text("Test OK" + csTab + "mm :" + csTab + "300");

SetTabStops(txt6);

sec1.Paragraphs.Add(txt6);

Aspose.Pdf.Text txt3 = new Text("Test OK" + csTab + " :" + csTab + "300");

SetTabStops(txt3);

sec1.Paragraphs.Add(txt3);

Aspose.Pdf.Text txt5 = new Text("Test OK" + csTab + "mm:" + csTab + "300");

SetTabStops(txt5);

sec1.Paragraphs.Add(txt5);

sec1.Paragraphs.Add(new Aspose.Pdf.Text(" "));

// font = Arial

Aspose.Pdf.Text txt12 = new Text("Test OK" + csTab + ":" + csTab + "300");

txt12.TextInfo.FontName = "Arial";

SetTabStops(txt12);

sec1.Paragraphs.Add(txt12);

Aspose.Pdf.Text txt16 = new Text("Test OK" + csTab + "mm :" + csTab + "300");

txt16.TextInfo.FontName = "Arial";

SetTabStops(txt16);

sec1.Paragraphs.Add(txt16);

Aspose.Pdf.Text txt13 = new Text("Test NOT OK" + csTab + " :" + csTab + "300");

txt13.TextInfo.FontName = "Arial"; // comment this line and output is OK

SetTabStops(txt13);

sec1.Paragraphs.Add(txt13);

Aspose.Pdf.Text txt15 = new Text("Test NOT OK" + csTab + "mm:" + csTab + "300");

txt15.TextInfo.FontName = "Arial"; // comment this line and output is OK

SetTabStops(txt15);

sec1.Paragraphs.Add(txt15);

Response.ClearContent();

Response.ClearHeaders();

Response.ContentType = "application/pdf";

Response.AddHeader("Content-Disposition", "attachment; filename=x.pdf");

pdf1.Save(Response.OutputStream);

try

{

pdf1.Save(Response.OutputStream);

}

catch (Exception)

{

throw;

}

Response.End();

}

Hi,

I have tested your code and was able to reproduce the error. I have logged this as PDFNET-4411 in our issue tracking system. We will try our best to resolve this as soon as possible.

Thanks.

With hotfix 3.6.2.0 solved.

Thanks, Arjen.