@Test public void multipleFiltersForOneRegionTest() throws IOException { final PdfReader pdfReader = TestResourceUtils.getResourceAsPdfReader(this, "test.pdf"); final Rectangle[] regions = new Rectangle[] {new Rectangle(0, 0, 500, 650), new Rectangle(0, 0, 400, 400), new Rectangle(200, 200, 500, 600), new Rectangle(100, 100, 450, 400)}; final RegionTextRenderFilter[] regionFilters = new RegionTextRenderFilter[regions.length]; for (int i = 0; i < regions.length; i++) regionFilters[i] = new RegionTextRenderFilter(regions[i]); MultiFilteredRenderListener listener = new MultiFilteredRenderListener(); LocationTextExtractionStrategy extractionStrategy = (LocationTextExtractionStrategy)listener.attachRenderListener(new LocationTextExtractionStrategy(), regionFilters); new PdfReaderContentParser(pdfReader).processContent(1, listener); String actualText = extractionStrategy.getResultantText(); String expectedText = PdfTextExtractor.getTextFromPage(pdfReader, 1, new FilteredTextRenderListener(new LocationTextExtractionStrategy(), regionFilters)); Assert.assertEquals(expectedText, actualText); }
public <E extends RenderListener> E attachRenderListener(E delegate, RenderFilter... filterSet) { delegates.add(delegate); filters.add(filterSet); return delegate; }
MultiFilteredRenderListener implements RenderListener { public <E extends RenderListener> E attachRenderListener(E delegate, RenderFilter... filterSet) { delegates.add(delegate); filters.add(filterSet); return delegate; } }
MultiFilteredRenderListener implements RenderListener { public <E extends RenderListener> E attachRenderListener(E delegate, RenderFilter... filterSet) { delegates.add(delegate); filters.add(filterSet); return delegate; } MultiFilteredRenderListener(); }
MultiFilteredRenderListener implements RenderListener { public <E extends RenderListener> E attachRenderListener(E delegate, RenderFilter... filterSet) { delegates.add(delegate); filters.add(filterSet); return delegate; } MultiFilteredRenderListener(); E attachRenderListener(E delegate, RenderFilter... filterSet); void beginTextBlock(); void renderText(TextRenderInfo renderInfo); void endTextBlock(); void renderImage(ImageRenderInfo renderInfo); }
MultiFilteredRenderListener implements RenderListener { public <E extends RenderListener> E attachRenderListener(E delegate, RenderFilter... filterSet) { delegates.add(delegate); filters.add(filterSet); return delegate; } MultiFilteredRenderListener(); E attachRenderListener(E delegate, RenderFilter... filterSet); void beginTextBlock(); void renderText(TextRenderInfo renderInfo); void endTextBlock(); void renderImage(ImageRenderInfo renderInfo);  }