We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Replace text from pdf


I need to replace some text from an existing pdf. I tried the following code but its replacing the first occurence only. My requirement is to replace all "testing data" to "test".

PdfContentEditor editor = new PdfContentEditor();


editor.replaceText("testing data", "test");


i am using pdf kit 3.7.0

Hi Sriman,

In order to replace all the occurrences of the text, you need to use setReplaceTextStrategy method. Please set the Scop value to REPLACE_ALL. Also, please make sure that you’re using the latest version at your end.

I hope this helps. If you find any further questions, please do let us know.


Thanks it worked. Its replacing the strings. But the file created after replacing the charcters is having a size more than double size of the actual file. I tested for a file of 112 KB and after replacement its coming a size of 235KB.

Any idea why the size differ this much ?

Hi Sriman,

We need to investigate this issue at our end. Please share the input PDF file and the code snippet. We’ll share the results with you accordingly.

We’re sorry for the inconvenience.