Ejemplo n.º 1
0
        public virtual void MultipleFiltersForOneRegionTest()
        {
            PdfDocument pdfDocument = new PdfDocument(new PdfReader(sourceFolder + "test.pdf"));

            Rectangle[] regions = new Rectangle[] { new Rectangle(0, 0, 500, 650), new Rectangle(0, 0, 400, 400), new
                                                    Rectangle(200, 200, 300, 400), new Rectangle(100, 100, 350, 300) };
            TextRegionEventFilter[] regionFilters = new TextRegionEventFilter[regions.Length];
            for (int i = 0; i < regions.Length; i++)
            {
                regionFilters[i] = new TextRegionEventFilter(regions[i]);
            }
            FilteredEventListener          listener           = new FilteredEventListener();
            LocationTextExtractionStrategy extractionStrategy = listener.AttachEventListener(new LocationTextExtractionStrategy
                                                                                                 (), regionFilters);

            new PdfCanvasProcessor(listener).ProcessPageContent(pdfDocument.GetPage(1));
            String actualText   = extractionStrategy.GetResultantText();
            String expectedText = PdfTextExtractor.GetTextFromPage(pdfDocument.GetPage(1), new FilteredTextEventListener
                                                                       (new LocationTextExtractionStrategy(), regionFilters));

            NUnit.Framework.Assert.AreEqual(expectedText, actualText);
        }
Ejemplo n.º 2
0
        public virtual void IllegalDifference()
        {
            PdfDocument pdf = new PdfDocument(new PdfReader(sourceFolder + "illegalDifference.pdf"));

            PdfTextExtractor.GetTextFromPage(pdf.GetFirstPage());
        }