PdfTextExtractor { public static String getTextFromPage(PdfPage page, ITextExtractionStrategy strategy, Map<String, IContentOperator> additionalContentOperators) { PdfCanvasProcessor parser = new PdfCanvasProcessor(strategy, additionalContentOperators); parser.processPageContent(page); return strategy.getResultantText(); } private  PdfTextExtractor(); static String getTextFromPage(PdfPage page, ITextExtractionStrategy strategy, Map<String, IContentOperator> additionalContentOperators); static String getTextFromPage(PdfPage page, ITextExtractionStrategy strategy); static String getTextFromPage(PdfPage page);  }
@Test @LogMessages(messages = @LogMessage(messageTemplate = LogMessageConstant.PDF_REFERS_TO_NOT_EXISTING_PROPERTY_DICTIONARY)) public void noSpecifiedDictionaryInPropertiesTest() throws IOException { String inFile = sourceFolder + "noSpecifiedDictionaryInProperties.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile)); String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1)); Assert.assertEquals("", text); pdfDocument.close(); }
@Test @LogMessages(messages = @LogMessage(messageTemplate = LogMessageConstant.PDF_REFERS_TO_NOT_EXISTING_PROPERTY_DICTIONARY)) public void noPropertiesInResourcesTest() throws IOException { String inFile = sourceFolder + "noPropertiesInResources.pdf"; PdfDocument pdfDocument = new PdfDocument(new PdfReader(inFile)); String text = PdfTextExtractor.getTextFromPage(pdfDocument.getPage(1)); Assert.assertEquals("", text); pdfDocument.close(); }