Extract text using Apache Tika
JPedal is compatible with Apache Tika’s Parser interface, meaning you can use it as a drop-in replacement in an existing Tika application.
Currently, it only supports unstructured text, although we have plans in the future to support structured text.
Example usage
try (final TikaInputStream tik = TikaInputStream.get(Paths.get("path/file.pdf"))) {
final PDFParser parser = new PDFParser();
// Set the writeLimit to -1 otherwise only the first 100000 characters are parsed
final BodyContentHandler handler = new BodyContentHandler(-1);
// Ability to set a password if necessary
final Metadata metadata = new Metadata();
// metadata.set(PDFParser.PASSWORD, "password");
// parseContext is not required so can be null
parser.parse(tik, handler, metadata, null);
// Print the result
System.out.println(handler);
} catch (final IOException | SAXException | TikaException e) {
e.printStackTrace();
}
More information about PDFParser.
Just click a button below if you have more questions or need any help