Save the hidden texts on word document to PDF

With the help of Spire.Doc for .NET, we can easily hide the texts on the word document in C#. This article will demonstrate how to get word hidden text to show on the resulted PDF page by using Spire.Doc.

Note: Before Start, please download the latest version of Spire.Doc and add Spire.Doc.Doc.dll in the bin folder as the reference of Visual Studio.

Here comes to the steps of how to save the hidden texts on word document to PDF in C#. Firstly, view the original word document with hidden texts:

Save the hidden texts on word document to PDF

Step 1: Create a new word document and load the document from file.

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

Step 2: When convert to PDF file, set the property IsHidden as true.

ToPdfParameterList pdf = new ToPdfParameterList();
pdf.IsHidden = true;

Step 3: Save the document to file and apply the style in the step 2.

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

Effective screenshot of the resulted PDF page with the hidden texts on the original word document:

Save the hidden texts on word document to PDF

Full codes:

static void Main(string[] args)
{
    Document doc = new Document();
    doc.LoadFromFile("sample.docx");

    ToPdfParameterList pdf = new ToPdfParameterList();
    pdf.IsHidden = true;

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

}