Hyperlinks are not rendered properly when converting DOCX to PDF

Hi,

When converting a DOCX with some hyperlinks in the text to PDF, the links do not show properly in the output.

Code:

var doc = new Document(@"test.docx");
doc.Save(@"asposeoutput.pdf");

I’ve attached the test documents and a screenshot for your reference. Could you please help us check?

test_aspose.zip (72.5 KB)

Thanks,

@ServerSide527

When converting a DOCX file containing hyperlinks to PDF using Aspose.Words, if the hyperlinks are not rendering properly, you may need to ensure that the PDF save options are configured correctly.

Here’s a sample code snippet that demonstrates how to set up the conversion with the necessary options:

using Aspose.Words;
using Aspose.Words.Saving;

class Program
{
    static void Main()
    {
        // Load the DOCX document
        Document doc = new Document("test.docx");

        // Configure PDF save options
        PdfSaveOptions saveOptions = new PdfSaveOptions
        {
            // Ensure that hyperlinks are preserved in the PDF
            ExportDocumentStructure = true
        };

        // Save the document as PDF
        doc.Save("asposeoutput.pdf", saveOptions);
    }
}

In this example, the ExportDocumentStructure property is set to true, which helps in preserving the document’s structure, including hyperlinks, when converting to PDF.

If you continue to experience issues with hyperlinks not displaying correctly, please check the following:

  1. Ensure that the hyperlinks in the DOCX file are correctly formatted.
  2. Verify that you are using the latest version of Aspose.Words, as updates may include fixes for known issues.

If the problem persists, consider sharing the specific DOCX file and the output PDF for further investigation.

For more detailed guidance on exporting documents and preserving their structure, you can refer to the official documentation on exporting Word document structures to PDF here [1].

Sources:
[1]: Export Word Document Structure to PDF Document - Aspose

@ServerSide527 Unfortunately, the problem is not reproducible on my side.
Aspose.Words: out.pdf (57.3 KB)
MS Word: ms.pdf (109.2 KB)

Hi @alexey.noskov

Thanks for checking.

After further investigation I found the issue was caused by a manual

doc.UpdateFields()

call after loading the document, before the PDF is created. Some hyperlinks have urls printed next to the text for some reason.

Since I can observe the same behaviour in Word when I do Ctrl+A/F9 to update fields, so it might not be an Aspose issue. I will check further on our end.

Thanks,

@ServerSide527 Thank you for additional information. Please feel free to ask in case of any further issues. We are always glad to help you.