Preserve or disable hyperlinks from word to PDF conversion

Hyperlinks give more additional information for readers and it is widely used on our word documents. Spire.Doc has a powerful function of operating the word elements of hyperlinks. Developers can add hyperlinks, modify and remove hyperlinks from word documents. Spire.Doc also supports to preserve hyperlinks or not in word to PDF conversion. This article will show you how to preserve hyperlinks or disable the hyperlinks in C# when converting word document into PDF file format.

Here comes to the code snippets of how to disable or preserve hyperlinks from word to PDF.

Step 1: Load a word documents with hyperlinks.

Document doc = new Document();
doc.LoadFromFile("Sample.docx");

Step 2: Create an instance of ToPdfParameterList.

ToPdfParameterList pdf = new ToPdfParameterList();

Step 3: Set DisableLink to true to remove the hyperlink effect for the result PDF page.

//set DisableLink to false to preserve the hyperlinks
pdf.DisableLink = true;

Step 4: Save the PDF file.

doc.SaveToFile("result.pdf", pdf);

Effective screenshot of preserve the hyperlinks from the result PDF page.

Preserve or disable hyperlinks from word to PDF conversion

Effective screenshot of disabled the hyperlinks from the result PDF page.

Preserve or disable hyperlinks from word to PDF conversion

Full codes of how to preserve the hyperlinks or not when convert word document to PDF file:

public WordtoPDFwithHyperlinks()
{
    Document doc = new Document();
    doc.LoadFromFile("Sample.docx");

ToPdfParameterList pdf = new ToPdfParameterList();

    //set DisableLink to false to preserve the hyperlinks
    pdf.DisableLink = true;

    doc.SaveToFile("result.pdf", pdf);
}