Range.Replace does not work for text frame using NET

When the source document (what we .Open()) is in docx format then a Replace won’t find (and replace) text that’s in a textbox. If the source document is RTF or DOC it will.

Hi Walden,

Thanks for your query. I have tested the scenario and have not found any issue while using latest version of Aspose.Words for .NET. Please use the latest version of Aspose.Words for .NET. If you still face problem, please share your document along with code for investigation purposes.

Please see the attached repro code. I didn’t include the license file as I’m not sure what the standard is for posting those, but I’m sure you have a license file hanging around. :slight_smile:

There are two “source” documents, one a docx and one an rtf. The rtf is the .docx saved as .rtf from w/in Word 2010 – so they’re identical except for format. You’ll see the code is simple enough, open the source document, do a global replace of $$GenerationDate$$ w/the current datetime and save as PDF.

In the docx to pdf output you’ll see the $$GenerationDate$$ values aren’t replaced when they’re in textboxes, in the rtf to pdf output you’ll see they are.

This is on version 11.6.0.0

Hi Walden,

Thanks for your query. I have managed to reproduce the same issue at my side. I have logged this issue as WORDSNET-6730 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved.

Please use the following code snippet as a workaround.

Document d = new Document(MyDir + "Source.docx");

MemoryStream stream = new MemoryStream();

d.Save(stream, SaveFormat.Docx);


d = new Document(stream);

d.Range.Replace("$$GenerationDate$$", DateTime.Now.ToString(), false, false);

d.Save(MyDir + "FromDocx.pdf");

We apologize for your inconvenience.

No problem, bugs happen. The workaround is applied and working fine. Get it fixed when you can, but I’m ok w/the workaround for now.

BTW, is there somewhere we can see the open issues. I know the issues are listed in the release notes when closed, but can we track the issue prior to it showing up in release notes?

Hi


Thanks for your request. The issue you have reported is already resolved int he current code base. The fix will be included into the next version of Aspose.Words that comes out at the end of this month.
Unfortunately, there is no public access to our defects database.

Best regards,

The issues you have found earlier (filed as WORDSNET-6730) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.