I am currently using the below code to extract the content and metadata of PDF files using TIKA library. Is there a way to read specific page OR limit the parsing to first few pages in TIKA?
public static void main(final String[] args) throws IOException,TikaException, SAXException {
BodyContentHandler handler = new BodyContentHandler();
Metadata metadata = new Metadata();
FileInputStream inputstream = new FileInputStream(new File("test/test.pdf"));
ParseContext pcontext = new ParseContext();
//parsing the document using PDF parser
AutoDetectParser pdfparser = new AutoDetectParser();
pdfparser.parse(inputstream, handler, metadata,pcontext);
//getting the content of the document
System.out.println("Contents of the PDF :" + handler.toString());
//getting metadata of the document
//System.out.println("Metadata of the PDF:");
String[] metadataNames = metadata.names();
System.out.println(metadata.get("xmpTPg:NPages"));
for(String name : metadataNames) {
System.out.println(name+ " : " + metadata.get(name));
}
}