Convert Non Searachable PDF to Searchable PDF using Aspose.PDF

Hi Hari,


Thanks for your patience. In reference to above investigation issue PDFNEWJAWA-35737, our product team has tested your sample code and unable to reproduce the issue too. However by investigating your exception message, we have noticed that the reason of the exception is incorrect html file that read and returned by method “invoke”. You may read file in another way without adding symbols, please check sample code snippet as following. Hopefully it will help you to accomplish the task.

//File file = new File(myDirOcr +
“out.html”);
<o:p></o:p>

//StringBuilder fileContents = new StringBuilder((int) file.length());

//Scanner scanner = null;

//try {

// scanner = new Scanner(file);

// String lineSeparator = System.getProperty("line.separator");

//

// while (scanner.hasNextLine()) {

// fileContents.append(scanner.nextLine() + lineSeparator);

// }

// } catch (FileNotFoundException e) {

// e.printStackTrace();

// } finally {

// if (scanner != null)

// scanner.close();

// }

//return fileContents.toString();

try

{

int len;

char[] chr = new char[4096];

final StringBuffer buffer = new StringBuffer();

final FileReader reader = new FileReader(myDir + "out.html");

try

{

while ((len = reader.read(chr)) > 0)

{

buffer.append(chr, 0, len);

}

} finally

{

reader.close();

}

return buffer.toString();

} catch (FileNotFoundException e)

{

e.printStackTrace();

} catch (java.lang.Exception exc)

{

exc.printStackTrace();

}

return null;


Best Regards,

The issues you have found earlier (filed as PDFNEWJAVA-35395) have been fixed in Aspose.Pdf for Java 11.5.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.