ReplaceText to highlight words


We are currently evaluating Aspose and we found a bug with the ReplaceText feature.
We want to use this feature to remove some words in a document.
The document contains hundred of I/We words and we need to remove the I/ without loosing the document layout.
We want to put a black background for the I/ so it will appear as black squares.

When we do this using the TextProperties class with ReplaceText it put black square but not under the correct letter. (might be at any position in the line of text).
We use the example you provided in and it works great to change font color but it doesn’t work for background.
Can you provide a quick fix for this ?


Eric Moreau

This message was posted using Page2Forum from Highlighting Text with replaceText Method - Aspose.Pdf.Kit for Java

Hi Eric,

Thank you very much for considering Aspose.

Could you please make sure that you’re using the latest version of Aspose.Pdf.Kit for Java? If you still find the same issue then please share the input PDF file along with the particular code snippet which you’re using at your end, so we could investigate the issue over here. You’ll be updated with the results accordingly.

We’re sorry for the inconvenience.

above issue exists with me. i am using the lates jar

Hi Shibu,

Thanks for contacting support.

Can you please share some details regarding the issue you are facing i.e. Is the background color not appearing properly behind the word development or text is not properly being replaced in document. Please share the code snippet and input document that you are using so that we can test the scenario at our end. We are sorry for this inconvenience.

I am currently evaluating Aspose. I have succeded in converting word document to pdf using aspose. Now i want to highlight certain words(case insensitive) in the obtained pdf . For that i am using the following code.

PdfContentEditor contentEditor = new PdfContentEditor();
TextProperties textProperties = new TextProperties();
contentEditor.replaceText(“development”, “development”, textProperties);
contentEditor.replaceText(“and”, “and”, textProperties);“D:/Document.Doc2PdfSave22.pdf”);

My highlighted pdf is attached.Background color is not appearing properly behind the word “and
and text development is not properly replaced in document. Please give me solution.


Hi Shibu,

Thanks for sharing the required resources.

I have tested the scenario and have observed that not all instances of word development and and are being replaced (highlighted). For the sake of correction, I
have logged it in our issue tracking system as PDFKITJAVA-33256.

Besides this, I have also observed that some unwanted words/characters are also being highlighted i.e. Notice larg, con, nation, rovid, A le and pre words on first page of PDF file. I have separately logged this issue as PDFKITJAVA-33257. We will investigate these issues in details and will keep you updated on the status of a correction. We apologize for your inconvenience.