Free Support Forum - aspose.com

Remove Document Footer unicode text dynamically WPF c#


#1

Hi Aspose Team,

We are using Apsoe.Words .NET for our application developed using C# WPF technology.

Requirement: To Replace document Footer specific part of Text dynamically.
Here complete text is dynamic (coming from Data Base) hard-coding not possible.

Problem:

I am facing issue in Replacing the Footer text as Unicode’s or special characters are present in the string.
Footer.Range.Rplace( ) method does is not working here. I am trying to make these Unicode as null. But not working.
Below is my sample code for your reference:
Code I am using:

Document docFooterRplace = new Document(JobFolderPath + filename);
HeaderFooterCollection headersFooters = docFooterRplace.FirstSection.HeadersFooters;
HeaderFooter footer = headersFooters[Aspose.Words.HeaderFooterType.FooterPrimary];
FindReplaceOptions options = new FindReplaceOptions
{
MatchCase = false,
FindWholeWordsOnly = false
};

footer.Range.Replace(new System.Text.RegularExpressions.Regex(@"[^\u0014-\u007E]"), “”, options);

docFooterRplace.Save(JobFolderPath + “\HeaderFooter.ReplaceText.doc”);

Attached code line shows the codes or special characters with Red boxes. I need only text to come and no Codes or special characters. So Replace method works.

FooterUnicodes.png (13.1 KB)

Request you to please provide some solution on this.

Please let me know if anything more required.

Thanks in advance.


#2

@verelly

Please ZIP and attach your input Word document here for testing. We will investigate the issue on our side and provide you more information.


#3

Please find the attached zipped containing input file.
But, application will have multiple files in similar format as input files with DIFFERENT set of data.

04.05.00-B___ABC.DOCx.zip (19.3 KB)

Thanks.


#4

@verelly

Unfortunately, we have not found any Unicode’s or special characters in the document. Could you please share the content’s detail that you want to replace? We will investigate the issue and provide you more information on it.


#5

please refer the attached image “footerunicode.png” showing Unicode with red border box.

FooterUnicodes.png (13.1 KB)

“\u0014…” “\u001” etc…

Also present is the code that i am using

Document docFooterRplace = new Document(JobFolderPath + filename);
HeaderFooterCollection headersFooters = docFooterRplace.FirstSection.HeadersFooters;
HeaderFooter footer = headersFooters[Aspose.Words.HeaderFooterType.FooterPrimary];
FindReplaceOptions options = new FindReplaceOptions
{
MatchCase = false,
FindWholeWordsOnly = false
};
footer.Range.Replace(new System.Text.RegularExpressions.Regex(@"[^\u0014-\u007E]"), “”, options);
docFooterRplace.Save(JobFolderPath + “\HeaderFooter.ReplaceText.doc”);

Thanks.


#6

@verelly

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-18584. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.


#7

Ok thanks for the update.
Waiting for you resolution.

Thanks.