PDFParser extends AbstractParser implements Initializable { @Field void setDetectAngles(boolean detectAngles) { defaultConfig.setDetectAngles(detectAngles); }  Set<MediaType> getSupportedTypes(ParseContext context); void parse(
            InputStream stream, ContentHandler handler,
            Metadata metadata, ParseContext context); PDFParserConfig getPDFParserConfig(); void setPDFParserConfig(PDFParserConfig config); boolean getEnableAutoSpace(); @Field void setEnableAutoSpace(boolean v); boolean getExtractAnnotationText(); void setExtractAnnotationText(boolean v); boolean getSuppressDuplicateOverlappingText(); @Field void setSuppressDuplicateOverlappingText(boolean v); boolean getSortByPosition(); @Field void setSortByPosition(boolean v); @Field void setOcrStrategy(String ocrStrategyString); @Field void setOcrImageType(String imageType); void setInitializableProblemHandler(InitializableProblemHandler initializableProblemHandler); @Field void setDropThreshold(float dropThreshold); @Field void setMaxMainMemoryBytes(long maxMainMemoryBytes); @Override void initialize(Map<String, Param> params); @Override void checkInitialization(InitializableProblemHandler handler); static final String PASSWORD; }
@Test public void testAngles() throws Exception { PDFParserConfig pdfParserConfig = new PDFParserConfig(); pdfParserConfig.setDetectAngles(true); ParseContext parseContext = new ParseContext(); parseContext.set(PDFParserConfig.class, pdfParserConfig); String xml = getXML("testPDF_angles.pdf", parseContext).xml; assertContainsCount("<div class=\"page\">", xml, 1); assertContains("IN-DEMAND", xml); assertContains("natural underground", xml); assertContains("transport mined materials", xml); }
@Test public void testUnmappedUnicodeStats() throws Exception { List<Metadata> metadataList = getRecursiveMetadata("testPDF_bad_page_303226.pdf", true); Metadata m = metadataList.get(0); int[] totalChars = m.getIntValues(PDF.CHARACTERS_PER_PAGE); int[] unmappedUnicodeChars = m.getIntValues(PDF.UNMAPPED_UNICODE_CHARS_PER_PAGE); if (totalChars[15] > 0) { assertEquals(3805, totalChars[15]); assertEquals(120, unmappedUnicodeChars[15]); } PDFParserConfig pdfParserConfig = new PDFParserConfig(); pdfParserConfig.setDetectAngles(true); ParseContext parseContext = new ParseContext(); parseContext.set(PDFParserConfig.class, pdfParserConfig); metadataList = getRecursiveMetadata("testPDF_bad_page_303226.pdf", parseContext,true); m = metadataList.get(0); totalChars = m.getIntValues(PDF.CHARACTERS_PER_PAGE); unmappedUnicodeChars = m.getIntValues(PDF.UNMAPPED_UNICODE_CHARS_PER_PAGE); if (totalChars[15] > 0) { assertEquals(3805, totalChars[15]); assertEquals(120, unmappedUnicodeChars[15]); } }