Hi,
I have a Word document that contains a paragraph with a soft line break. When I save this document as text, I expect this soft line break to be converted to a vertical tab \v but it is instead converted to a a line break \n\r.
Is there an option to modify this behavior and get a \v instead of a \r\n?
Thanks
See attached project.
I use Aspose.Words 16.4 for .Net
Hi Tahir,
See the attached file. It contains a vertical tab (0x0b) between the words Hello and World.
Document doc = new Document(MyDir + "Hello.docx");
doc.Range.Replace(ControlChar.LineBreak, "" + (char)0x0b, new FindReplaceOptions());
doc.Save(MyDir + "17.3.0.txt");
Hi Tahir,
The thing is, your code also converts the \n\r at the end of the text. But I guess when using your code, I can simply revert that last vertical tab back to a \n\r.
Thanks,
Christophe
Hi Tahir,
I use the HxD Hex Editor to see what is contained in the text file.
class ReplaceEvaluator : IReplacingCallback
{
///
/// This method is called by the Aspose.Words find and replace engine for each match.
///
ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)
{
if (e.MatchNode.GetText().Contains(ControlChar.LineBreak))
return ReplaceAction.Replace;
return ReplaceAction.Skip;
}
}
Document doc = new Document(MyDir + "Hello.docx");
FindReplaceOptions findreplace = new FindReplaceOptions();
findreplace.ReplacingCallback = new ReplaceEvaluator();
doc.Range.Replace(ControlChar.LineBreak, "" + (char)0x0b, findreplace);
doc.Save(MyDir + "17.3.0.txt");
Hi Tahir,
This interface is interesting, thanks for letting me know about it, I’ll play a bit with it.
Best regards,
Christophe