I am using that function to find a text in the pdf file and replace that text with another text. The problem is when I make inflate and then change the text and deflate, in the
Your assumption that text can be found literally in a content stream is wrong.
Suppose that you have a PDF with content Hello World. Then you could have a stream that looks like this:
q
BT
36 806 Td
0 -18 Td
/F1 12 Tf
(Hello World!)Tj
0 0 Td
ET
Q
But it can also look like this:
Q
BT
/F1 12 Tf
88.66 367 Td
(ld) Tj
-22 0 Td
(Wor) Tj
-15.33 0 Td
(llo) Tj
-15.33 0 Td
(He) Tj
ET
q
Your code will detect the word "Hello" in the former stream, but will miss it in the latter one.
A PDF viewer will render both streams in exactly the same way: you'll see "Hello World" at the exact same position.
Sometimes Strings are broken into smaller pieces, you'll often find text arrays to introduce kerning, etc... This is all standard practice in PDF.
PDF isn't a format that is suited for editing. I'm not saying it's impossible, but you're looking at a couple of weeks of extra programming if you want to meet your requirement of being able to replace one String with another one in a PDF stream.