Regarding Document to Text file conversion

Hi Helpdesk Team,

Can you please suggest me how to remove blank lines in word document to text file conversion in .net using aspose.words dll.
in converted txt file contains lot of empty lines which will have to be remove .
pl consider it as priority .

Thanks & Regards,
Sunil
9844024262

Hi Sunil,

Thanks for your inquiry. Please use the following code example to remove the empty paragraphs from the document. Hope this helps you. If the problem still remains, please attach your input Word document here for testing. I will investigate the issue on my side and provide you more information.

Document doc = new Aspose.Words.Document(MyDir + "in.docx");
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
    if (para.ToString(SaveFormat.Text).Trim().Equals(""))
        para.Remove();
}
doc.Save(MyDir + "Out.txt");

thank for your response,
Still there was a empty lines in the converted text file from document .
Pl check your end i’m attaching the document file in post .

Thanks & Regards,
Sunil

Hi Sunil,

Thanks for sharing the detail. In your case, I suggest you please use TxtSaveOptions.PreserveTableLayout property as shown in following code example. Hope this helps you. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "Ameritrade_NTF_Plat_0_O_03312014.doc");
foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
{
    if (para.ToString(SaveFormat.Text).Trim().Equals(""))
        para.Remove();
}
TxtSaveOptions options = new TxtSaveOptions();
options.PreserveTableLayout = true;
doc.Save(MyDir + "Out.txt", options);