Free Support Forum - aspose.com

Problem with ReplaceText function

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

I am using the function replaceText() for a pdf document. The pdf contains the word "test". I tried to replace the string test by the word "replaced" but i didn't success. But when searching for "replaced" it highlights the word "text".

I used the below code. Please i need help here or more clarification. I need to 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() {

}

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());

}

}

}

Hi Tony,

Thank you very much for considering Aspose.

Have you tried the latest version of Aspose.Pdf.Kit for Java? If so, please share the problematic PDF with us, so we could test the issue at our end. I would like to add that sometimes the issue is caused due to the particular contents or origin of the PDF file. We’ll look into the issue and provide you the resolution.

We’re sorry for the inconvenience.
Regards,