We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to make Linebreak invisible and remove it?

Hi,

Could you please let me know how to make Linebreak invisible and remove it from the document? Please provide with sample and code snippet.

Awaiting for your soon reply.

Hi

Thanks for your inquiry. Line break is a special character ā€œ\vā€. You can find and replace this character in your document. For example see the following code:

Document doc = new Document("in.doc");
NodeCollection runs = doc.GetChildNodes(NodeType.Run, true);
foreach (Run run in runs)
{
    if (run.Text.Contains("\v"))
    {
        run.Text = run.Text.Replace("\v", " ");
    }
}
doc.Save("out.doc");

Also please attach your document for testing if this code will not work for you.

Best regards.

Thanks for the quick update. I will check this later.

One more question. If this possible to insert more than 255 characters in the Form field Textbox. Is there any workaround? Please let me know if so.

Hi

Thanks for your inquiry. You can insert more that 255 symbols into the formfield using Aspose.Words. For example the following code inserts 520 symbols.

Document doc = new Document(@"Test291\in.doc");
string value = string.Empty;
for (char c = 'a'; c <= 'z'; c++)
{
    for (int i = 0; i < 20; i++)
    {
        value += c.ToString();
    }
}
doc.Range.FormFields["test"].Result = value;
doc.Save(@"Test291\out.doc");

Hope this helps.

Best regards.

Thanks for the update. Its working as expected. Is this possible to remove specific comments from the document?

Hi

Thanks for your inquiry. Yes, you can work with comments using Aspose.Words. For example the following code removes all comments from the document.

Document doc = new Document(@"Test292\in.doc");
//Get collection of comments in the document
NodeCollection comments = doc.GetChildNodes(NodeType.Comment, true);
//Remove all comments from the document
comments.Clear();
//Save the document
doc.Save(@"Test292\out.doc");

Also you can use RemoveAt method to remove specific comment.

//Remove second comments from the document
comments.RemoveAt(1);

Hope this helps.

Best regards.