Extra empty paragraphs are appeared after inserting one document into another using .NET

Hi,
I have a problem when I try to replace placeholders in a word document with the content of other word documents.
After the placeholder is a line break, when I replace the placeholder, I have a second line break in the main document.
I think the second linebreak comes from the other document. But until now I have no idea to delete the second line break.

I uploaded threefiles.
The main documnet is “Verfahrensstammdaten.doc” with the placeholder
“{@10008; Textbaustein:Fallzustaendig_Detail@}”. This placeholder should be replaced with the content from the file “Fallzustaendig_Detail.doc”. The file “Ergebnis.doc” is the result.file.zip (17.3 KB)

For the replacement I use this peace of code:
document.Range.Replace(new Regex(platzhalterwert.Platzhalterinfo.Definition), string.Empty, new FindReplaceOptions(replaceHandler));

Please help.

@b.hauffe

To ensure a timely and accurate response, please attach the following resources here for testing:

  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

@tahir.manzoor,
here the wanted console application.

Thanks for the fast answer.Aspose-Support.zip (10.0 MB)

@b.hauffe

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-21145 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@b.hauffe

It is to inform you that the issue which you are facing is actually not a bug in Aspose.Words. So, we have closed this issue (WORDSNET-21145) as ‘Not a Bug’.

There is one paragraph break in the subdoc and two paragraph breaks in the main document. Paragraph break from the subdoc is removed in the code, two empty paragraphs are left. To get the desired result please add paragraph break to the regex ("&p") as shown below.

doc.Range.Replace(new Regex("{@10008; Textbaustein:Fallzustaendig_Detail@}&p"), string.Empty, new FindReplaceOptions(replaceHandler));