Hello,
I'm trying to store the inline images from a PDF to a local folder, but
can't find any valid example. I can only use the RecursiveParserWrapper to
get all the available metadata, but not the binary image content.

This is my code:

RecursiveParserWrapper parser = new RecursiveParserWrapper(
      new AutoDetectParser(),
      new BasicContentHandlerFactory(HANDLER_TYPE.XML, -1)
);
Metadata metadata = new Metadata();
ParseContext context = new ParseContext();
PDFParserConfig config = new PDFParserConfig();
PDFParser p;
config.setExtractInlineImages(true);
config.setExtractUniqueInlineImagesOnly(false);
context.set(org.apache.tika.parser.pdf.PDFParserConfig.class, config);
context.set(org.apache.tika.parser.Parser.class, parser);

InputStream is =
PdfRecursiveExample.class.getResourceAsStream("/BA200PDE.PDF");
//parsing the file
ToXMLContentHandler handler = new ToXMLContentHandler(new
FileOutputStream(new File("out.txt")), "UTF-8");
parser.parse(is, handler, metadata, context);

How can I store each image file to a folder?

Thanks
Andrea

Reply via email to