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


#1

Hi,

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;                    
            }
        }

        
        document.Save(
            destinationPath,
            Aspose.Words.SaveFormat.Pdf);

#2

@pradeepdone,

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");