Hi,
I am using the function replaceText()
for a PDF document. The PDF contains the word “test”. I tried to replace the string “test” with the word “replaced” but it didn’t work. However, searching for “replaced” highlights the word “text”.
I used the following code. Please help me or provide more clarification. I need change a word inside a PDF file. What is the best way to do it using Aspose?
package samples.contentEditor;
import com.aspose.pdf.kit.*;
public class ReplaceText {
public ReplaceText() {
// Constructor
}
public static void main(String args[]) throws Exception {
try {
PdfContentEditor editor = new PdfContentEditor();
editor.bindPdf("C:\\Documents and Settings\\Ever\\Desktop\\abc\\Scan-Family Wealth-18AUG_searchable_searchable.pdf");
editor.replaceText("test", "replaced");
editor.save("C:\\Documents and Settings\\Ever\\Desktop\\abc\\Scan-Family Wealth-18AUG_searchable_searchable.pdf");
} catch (java.io.IOException ioe) {
System.out.println(ioe.getMessage() + ioe.getStackTrace());
}
}
}