Free Support Forum -

Phantom empty links created when using localhyperlink in tables

I am creating a table of contents index page in my pdf. I call this DrawText function twice, once to add the text name of the document being indexed, and the second time to draw the page number in the pdf that document is located. Each text fragment has a localhyperlink to the page in the pdf document. What I’m finding is that the localhyperlinks are duplicated from about halfway down the index page on the extreme left hand edge, but with no text.

static private void DrawText(string text, int pageNumber, Row row, int indentationLevel = 0, bool isSectionHeader = false, bool italics = false)
            var fragment = new TextFragment(text);
                fragment.Hyperlink = new LocalHyperlink()
                    TargetPageNumber = pageNumber
            var cell = row.Cells.Add();
            MarginInfo cellMargin = new MarginInfo()
                Bottom = 1.8f,
                Top = 1.8f
            cellMargin.Left = 5 * indentationLevel;
            cell.Margin = cellMargin;

The function below is what creates the pdf page for the table of contents

static private Table CreateNewTOCPage(Document pdfDocument, int numberIndexPagesAdded)
            Page pageTOC = pdfDocument.Pages.Insert(numberIndexPagesAdded);
            pageTOC.PageInfo.Margin = new MarginInfo(20, 20, 20, 20);
            Table tableTOC = new Table
                ColumnWidths = "90% 10%"

            return tableTOC;

and this is how the two functions are called:

        var tableTOC = CreateNewTOCPage(pdfDocument, ++numberIndexPagesAdded);
        foreach (var document in documents)
            Row row = tableTOC.Rows.Add();

            DrawText(document.Title, nextDocumentStartIndex, row);
            DrawText(nextDocumentStartIndex.ToString(), nextDocumentStartIndex, row);

            nextDocumentStartIndex += document.PageImageURLs.Count;


Thank you for contacting support.

Would you please share your source and generated PDF documents with us along with screenshots highlighting the existence of hyperlinks without text. Shared code snippet includes some undefined variables; therefore, please update the code snippet so that we may try to reproduce and investigate it further. Before sharing requested data, please ensure using Aspose.PDF for .NET 18.10 in your environment.