Doubled text upon table page break when a Tabstop is used

Hi Tommy, here’s a weird bug…

I use Apose.Pdf to generate labels, so I basically do a table with fixed cell dimensions. In those cells, some text has to be right aligned, so I added a right-aligned tabstop. Up to here, everything’s OK. But when the table breaks onto a new page, the left-aligned text (before the tabstop) is duplicated for the first cell of the new page. After that, everything’s back to normal.

Here’s a sample code that illustrates the problem. I tried to keep it as simple as possible, but it’s still long, sorry for that. (attachment is the result)

Thanks,

Dominic.
p.s. Aspose.Pdf 2.9.0.0 used

---------------------------
const float MM2PT = 2.8346456692913385826771653543307f; // millimeters to point
int NB_LABELS = 35;

// Create PDF document
Aspose.Pdf.Pdf pdfDocument = new Aspose.Pdf.Pdf();

pdfDocument.PageSetup.PageHeight = Aspose.Pdf.PageSize.LetterHeight;
pdfDocument.PageSetup.PageWidth = Aspose.Pdf.PageSize.LetterWidth;
pdfDocument.PageSetup.Margin.Top = pdfDocument.PageSetup.Margin.Bottom = 13 * MM2PT;
pdfDocument.PageSetup.Margin.Left = pdfDocument.PageSetup.Margin.Right = 4 * MM2PT;

Aspose.Pdf.Section pdfSection;
pdfSection = pdfDocument.Sections.Add();

// Create table
Aspose.Pdf.Table pdfTable = new Aspose.Pdf.Table();
pdfSection.Paragraphs.Add(pdfTable);

pdfTable.Alignment = Aspose.Pdf.AlignmentType.Center;

pdfTable.IsFirstRowRepeated = false;
pdfTable.IsRowBroken = false;

float labelWidth = 66.7f * MM2PT;
float spacer = 4 * MM2PT;
float height = 25.4f * MM2PT;

StringBuilder build = new StringBuilder(labelWidth.ToString());
build.Append(" “);
build.Append(spacer.ToString());
build.Append(” “);
build.Append(labelWidth.ToString());
build.Append(” “);
build.Append(spacer.ToString());
build.Append(” “);
build.Append(labelWidth.ToString());
build.Append(” “);
build.Append(spacer.ToString());
build.Append(” ");
build.Append(labelWidth.ToString());
pdfTable.ColumnWidths = build.ToString();

Aspose.Pdf.Row pdfRow = null;
Aspose.Pdf.Cell pdfCell;
Aspose.Pdf.Text pdfText;
Aspose.Pdf.Segment pdfSegment;

Aspose.Pdf.TextInfo pdfTextInfo = new Aspose.Pdf.TextInfo();
pdfTextInfo.FontSize = 10;
pdfTextInfo.FontName = “Helvetica”;

// Output labels
for (int i=0; i
if (i % 3 == 0) { // new row
pdfRow = pdfTable.Rows.Add();
pdfRow.DefaultCellTextInfo = pdfTextInfo;
pdfRow.FixedRowHeight = height;
}
else {
pdfRow.Cells.Add(); // spacer
}

pdfCell = pdfRow.Cells.Add();
pdfCell.DefaultCellTextInfo = pdfTextInfo;

pdfText = new Aspose.Pdf.Text();
pdfText.ID = “label” + i;

// Add left aligned text
pdfSegment = pdfText.Segments.Add();
pdfSegment.Content = “test”;
pdfSegment.TextInfo = pdfTextInfo;

// Add right aligned tab.
pdfText.TabStops = new Aspose.Pdf.TabStops();
Aspose.Pdf.TabStop pdfTabStop = pdfText.TabStops.Add();
pdfTabStop.Position = labelWidth - pdfCell.Padding.Left - pdfCell.Padding.Right;
pdfTabStop.AlignmentType = Aspose.Pdf.TabAlignmentType.Right;

pdfSegment = pdfText.Segments.Add();
pdfSegment.Content = “\tP”;

pdfTextInfo = pdfCell.DefaultCellTextInfo.Clone() as Aspose.Pdf.TextInfo;
pdfSegment.TextInfo = pdfTextInfo;

// Add paragraph to table cell
pdfCell.Paragraphs.Add(pdfText);
}

// Display the PDF document
pdfDocument.Save(“test.pdf”, Aspose.Pdf.SaveType.OpenInAcrobat, Response);

Hi,

Thank you for considering Aspose.

I will test and solve this problem. This may need several days.

This bug has been fixed in the new hotfix.