Free Support Forum -

Inconstant TabStop behavior when word wrapping


We are having a problem with TabStops and word wrapping. This happens within a Page.Paragraph and a Table.Row.Cell.

The problem is that TabStops do not exhibit contestant behavior and unwanted behavior when a line overflows (or wraps) to the next line. Also content that is wider than the tabstops do not line up from one example to another. Some times the line wraps before it need to (space is sufficient to fit but it still wraps).

Referencing the example below here are some problems that happen within the page and within a cell. The Cell is there to show how much space is there and makes the rows easier to distinguish (IMO).

  1. Word Length 0, Row 8 is missing “[9]”
  2. Word Length 0, Row 9 is missing “[9]”
  3. Word Length 0, Row 10 has the control “$TAB”
  4. Word Length 1, Row 8 is missing “[S9]” and “[S10]”
  5. Word Length 10, Row 2 and Row 3 “[Supercalif2]” is not in the same horizontal position
  6. Word Length 10, Row 10 Text is written on top of one another.
    The errors happen more than once in this example.
    AsposePDFTabStopWrapping.pdf (12.4 KB)

I know there is a lot going on here and tell me if it is easier for me to raise separate topics.

Thanks, DenisW

Code Sample:

    static void Main(string[] args)
        License license = new License()
            Embedded = true

        var pdf = new Document();
        var page = pdf.Pages.Add();

        page.Paragraphs.Add(new TextFragment("On the Page"));
        AddTabStop(ref page, false);

        page.Paragraphs.Add(new TextFragment(Environment.NewLine));

        page.Paragraphs.Add(new TextFragment("In a Cell"));
        AddTabStop(ref page, true);


    static void AddTabStop(ref Page page, bool InCell)
        int TABSTOP_WIDTH = 50;
        var wordlengths = new int[] {

        foreach (int wordlength in wordlengths)
            page.Paragraphs.Add(new TextFragment($"Word Length:{wordlength}"));

            var table = new Table();
            table.ColumnWidths = (PageSize.PageLetter.Width - 50).ToString();

            for (int iRow = 1; iRow <= 10; iRow++)
                var row = table.Rows.Add();
                var cell = row.Cells.Add();
                cell.Border = new BorderInfo(BorderSide.All, 1, Color.Black);

                var ts = new TabStops();
                var sb = new StringBuilder();
                sb.Append($"Row {iRow}");
                for (int iTab = 1; iTab <= iRow; iTab++)
                    ts.Add(iTab * TABSTOP_WIDTH);
                    sb.Append("Supercalifragilisticexpialidocious".Substring(0, wordlength));

                var tf = new TextFragment(sb.ToString(), ts);
                if (!InCell)
            if (InCell)
            page.Paragraphs.Add(new TextFragment(Environment.NewLine));



Thank you for contacting support.

We have worked with the data shared by you and have been able to reproduce the issue in our environment. A ticket with ID PDFNET-44878 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

Moreover, please always create separate topics for separate issues because this helps us assist you effectively.

We are sorry for the inconvenience.