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

Free Support Forum - aspose.com

Re: Line Break Chars and Replaces

So how can I resolve not being able to put a paragraph break in? In the code below, I would ideally like to replace “linebreak” with ParagraphBreak so that I can continue the numbering sequence where <> is first found. That obviously does not work as I just learned. What is the alternative?


for (j = 0; j < RowCount2; j++)
{

if (j == (RowCount2 - 1))
{
KDocText = “” + KDocs.Rows[j][“document_name”];
rplcDoc.Range.Replace("<>", KDocText, false, false);
}
if (j == (RowCount2 - 2))
{
KDocText = KDocs.Rows[j][“document_name”] + “; and” + Aspose.Words.ControlChar.LineBreak + “<>”;
rplcDoc.Range.Replace("<>", KDocText, false, false);
}
else
{
KDocText = KDocs.Rows[j][“document_name”] + “; " + Aspose.Words.ControlChar.LineBreak + “<>”;
rplcDoc.Range.Replace(”<>", KDocText, false, false);
}
}

Hi Jake,

Thanks for your inquiry and sorry for the delayed response. Please attach the following resources here for testing.

  1. Please tell us about the version of Aspose.Words you’re currently using on your side.
  2. Please attach your input Word document ( that contains the line breaks )
  3. Please supply us with your output document that is generated by Aspose.Words which shows the undesired behavior. ( if available )
  4. Please supply us with your target Word document that contains paragraph breaks instead of line breaks ( You can use Microsoft Word to create this document ).

I will then investigate the issue on my side and provide you more information.

PS: I would also suggest you please read the find and replace section of documentation

Best regards,

Hello,


I am using aspose words enterprise 2.2.

I attached the provision that I am trying to run the replace operation on. I am trying to create a numbered list at a second heading level:
  1. The following documents should be attached to this document:
1.1 <>

I want the numbering to continue as follows:
  1. The following documents should be attached to this document:
1.1 Document 1
1.2 Document 2
1.3 Document 3

I know that would work if I could put a paragraph break in. What is the alternative?

-Jake

Hi Jake,


Thanks for the additional information. First off, you’re using a very old version of Aspose.Words; unfortunately, we don’t provide support for older released versions of Aspose.Words. We always encourage our customers to use the latest version of Aspose.Words as it contains newly introduced features, enhancements and fixes to the issues that were reported earlier. So, I would suggest you please upgrade to the latest version of Aspose.Words for .NET (13.7.0). You can download it from the following link:
http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/default.aspx

Secondly, please try run the following code to be able to achieve what you’re looking for:

Document doc = new
Document(@“C:\Temp\Contract+Docs+(1).docx”);

doc.Range.Replace(new Regex("<>."), new ReplaceHandler(), false);

doc.Save(@"C:\Temp\out.docx");


private class ReplaceHandler : IReplacingCallback

{

ReplaceAction IReplacingCallback.Replacing(ReplacingArgs e)

{

Paragraph para = (Paragraph)e.MatchNode.ParentNode;

DocumentBuilder builder = new DocumentBuilder((Document)para.Document);

builder.MoveTo(para);

builder.Writeln("Document 1");

builder.Writeln("Document 2");

builder.Write("Document 3");

e.Replacement = "";

return ReplaceAction.Replace;

}

}


I hope, this helps.

Best regards,