Replace text from pdf

Hi,

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.bindPdf(fileName);

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

editor.save(outputFile);

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.
Regards,

Hi,

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.
Regards,