This project has moved and is read-only. For the latest updates, please go here.

ReplaceText doesn't work when specifying formatting

Feb 3, 2014 at 5:36 PM
I'm having trouble getting the ReplaceText function to work when I specify formatting options. I want to replace all instances of "vv" with "w" for all text that is in the Sylfaen font:
Formatting matchFormatting = new Formatting();
matchFormatting.FontFamily = new FontFamily("Sylfaen");
docX.ReplaceText("vv", "w", true, RegexOptions.None, null, matchFormatting);
But nothing gets replaced. If I remove all parameters except the first two, it works but replaces all text and not just text in the Sylfaen font. Is there something I'm missing here? Thanks.
Feb 3, 2014 at 5:38 PM
Are u using newest source code version or binary file?
Feb 3, 2014 at 5:54 PM
I downloaded the latest source code (docx-87193.zip), compiled the library file (size of new .dll is 269,824 bytes), but it still doesn't work.
Feb 3, 2014 at 5:58 PM
One of the last patches was
  • Fix for "Format matching in ReplaceText does not work properly"
  • New method: RemoveTextInGivenFormat
  • Added unit test: Test_Paragraph_ReplaceTextInGivenFormat
  • Added 'VariousTextFormatting.docx' file for unit testing purposes
  • Moved ContainsEveryChildOf method to HelperFunction becasue it is shared by Contaner and Paragraph
  • Added new feature in Container class: RemoveTextInGivenFormat
  • Added unit test: Test_Document_RemoveTextInGivenFormat
Can you verify if you're doing things correctly just like in provided Unit Tests? This seems like it was tested and worked fine by Bartosz.
Feb 3, 2014 at 6:01 PM

Hi giangurgolo,

Please send me an example document where replaceText fails. Try to create a minimal example document as it will make it easier to fix this problem. It would also be great if you could send be a minimal code example.

Thanks,
Cathal

Feb 3, 2014 at 6:04 PM

I just saw MadBoy's reply, please try his suggestion first.

Thanks for the fast reply MadBoy :-)

Feb 3, 2014 at 6:05 PM
No problem :-) I saw you in 2 threads already since few days. Must be your free week ;-P