How to unhide the content of word document while converting to pdf



I am trying to convert word to pdf. But if there is any content is hidden in the content then that data is not seen in pdf. Can you please help me to unhide it while converting it to pdf so that hidden content is seen in the pdf. Below is the code i am using to convert to pdf.

Aspose.Words.Document document = new Aspose.Words.Document(filePath);

        foreach (Aspose.Words.Fields.Field field in document.Range.Fields)
            if (field.Type == Aspose.Words.Fields.FieldType.FieldDate
                || field.Type == Aspose.Words.Fields.FieldType.FieldTime
                || field.Type == Aspose.Words.Fields.FieldType.FieldFileName
                || field.Type == Aspose.Words.Fields.FieldType.FieldCreateDate
                || field.Type == Aspose.Words.Fields.FieldType.FieldPrintDate
                || field.Type == Aspose.Words.Fields.FieldType.FieldSaveDate)
                field.IsLocked = true;                    




Thanks for your inquiry. Please use Run.Font.Hidden property to remove hidden text font formatting. You can use following code example to get the desired output. Hope this helps you.

Document doc = new  Document(MyDir + "in.docx");
foreach (Paragraph par in doc.GetChildNodes(NodeType.Paragraph, true))
    par.ParagraphBreakFont.Hidden = false;
    foreach (Run run in par.GetChildNodes(NodeType.Run, true))
        if (run.Font.Hidden)
            run.Font.Hidden = false;

doc.Save(MyDir + "Out.pdf");


Whenever i am adding track changes to the document and hiding the text then this code is not working.

I mean to say if i hide any data in the word doc and convert to pdf then i am able to unhide the data with the above code but when i turn on the track changes and then hide some text and convert it to pdf then the content is not unhiding . Please help me on this .

Using AcceptAllRevisions i can get all the hidden text but track changes are not printing. But i need both the things can you please help me out on this.

Please find the attached source and converted doc’s for reference. (32.8 KB)



Thanks for your inquiry. Please use latest version of Aspose.Words for .NET 18.7 with following code example to get the desired output. We have attached the output PDF with this post for your kind reference. 18.7.pdf (22.3 KB)

Document doc = new Document(MyDir + "4.docx");
doc.LayoutOptions.IsShowHiddenText = true;
doc.LayoutOptions.RevisionOptions.ShowRevisionBalloons = true;
doc.Save(MyDir + "18.7.pdf");