Currently it is only possible to replace simple text that has not been encoded using Debenu Quick PDF Library and in Debenu PDF Tools Pro using the scripting feature which uses Debenu Quick PDF Library behind the scenes.

The function that lets you replace text is the ReplaceTag function. Basically, it is possible to replace some text in a PDF file if the text is not encoded. Debenu Quick PDF Library can create PDFs without encoded text, so it’s possible to use the ReplaceTag function with some PDFs that were created using our PDF SDK. However, the big catch is that you can only replace words of the same length. So you can replace Moby with Mary, but you can’t replace Moby with Jessica.

How does the ReplaceTag function work?

The ReplaceTag function simply replaces text in the page’s content stream, so for most documents it wouldn’t have any effect. For some simple documents it might be able to replace content, but it really depends on how the PDF was constructed. Essentially it’s the same as doing:

string content = DPL.GetContentStreamToString();
DPL.SetPageContentFromString(content.Replace("Moby", "Mary"));

If you created a PDF using Debenu Quick PDF Library and a standard font then the ReplaceTag function should work – however, for PDFs created with tools that do subsetted fonts or even kerning (where words will be split up) then the search text probably won’t be in the content in a simple format.

So in short, the ReplaceTag function will only work in some limited scenarios and isn’t a function that you can rely on for searching and replacing text.