Not getting links in converted file rtf to pdf Aspose.Words

Hello,
We are not getting links into the converted PDF which are available in the original RTF file using Aspose.Words. We are using licensed version of Aspose.Words 22.3 version. Please find code below which we are using to convert RTF to PDF. Also, original RTF and converted PDF file is attached.

private int _startConvert(string pInFile, string pOutFile, int languageId)
{
    Aspose.Words.License license = new Aspose.Words.License();
    license.SetLicense(AppDomain.CurrentDomain.BaseDirectory + "\\Aspose.Total.Product.Family.lic");
    Aspose.Words.Document document = null;//RTF to PDF

    document = new Aspose.Words.Document(pInFile);
    LayoutCollector collector = new LayoutCollector(document);
    LayoutEnumerator enumerator = new LayoutEnumerator(document);

    // Get Tables which are wider than their parent Sections
    Dictionary<Table, double> keyValuePairs = new Dictionary<Table, double>();
    foreach (Section section in document.Sections)
    {
        foreach (Table table in section.Body.Tables)
        {
            //table.AutoFit(AutoFitBehavior.AutoFitToContents);
            double tableWidth = GetTableWidth(collector, enumerator, table);

            if (section.PageSetup.PageWidth < tableWidth)
                keyValuePairs.Add(table, tableWidth);
        }
    }

    ArrayList uniqueSections = new ArrayList();
    foreach (KeyValuePair<Table, double> kvp in keyValuePairs)
    {
        Section section = (Section)kvp.Key.GetAncestor(NodeType.Section);
        if (!uniqueSections.Contains(section))
            uniqueSections.Add(section);
    }

    // for each sections, get the Tables with maximum widths
    Dictionary<Table, double> tablesWithMaxWidths = new Dictionary<Table, double>();
    foreach (Section section in uniqueSections)
    {
        double maxWidth = 0;
        Table theTable = null;
        foreach (KeyValuePair<Table, double> kvp in keyValuePairs)
        {
            if (kvp.Key.GetAncestor(NodeType.Section) == section)
            {
                if (kvp.Value > maxWidth)
                {
                    maxWidth = kvp.Value;
                    theTable = kvp.Key;
                }
            }
        }
        tablesWithMaxWidths.Add(theTable, maxWidth);
    }

    // Increase widths of Sections
    foreach (KeyValuePair<Table, double> kvp in tablesWithMaxWidths)
    {
        Section section = (Section)kvp.Key.GetAncestor(NodeType.Section);
        section.PageSetup.PageWidth = kvp.Value;
    }
    document.UpdatePageLayout();
    //New Code ends here
    PdfSaveOptions pdfSaveOptions = new PdfSaveOptions
    {
        SaveFormat = SaveFormat.Pdf
    };
    document.Save(pOutFile, pdfSaveOptions);
    return 0;
}

public static double GetTableWidth(LayoutCollector collector, LayoutEnumerator enumerator, Table table)
{
    double maxWidth = 0;
    foreach (Row row in table.Rows)
    {
        enumerator.Current = collector.GetEntity(row.LastCell.FirstParagraph);

        while (enumerator.MoveParent())
            if (enumerator.Type == LayoutEntityType.Row)
                break;

        // Get the width of Row
        double rowWidth = enumerator.Rectangle.Right;

        if ((rowWidth > maxWidth))
            maxWidth = rowWidth;
    }
    return maxWidth;
}

1591827050.zip (163.0 KB)

@Vaidehi123 Thank you for reporting this problem to us. For a sake of correction it has been logged as WORDSNET-23773. We will keep you informed and let you know once it is resolved.

@alexey.noskov Thank you. Is there any possibility to get this fixed in near future?

@Vaidehi123 At the moment we cannot provide you an estimate. Our developers will analyze the issue and we will provide you more information.

@alexey.noskov Thank you

1 Like

The issues you have found earlier (filed as WORDSNET-23773) have been fixed in this Aspose.Words for .NET 22.6 update also available on NuGet.