示例#1
0
        public void TestExtractColumnsCorrectly()
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // || RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                PageArea page = UtilsForTesting.GetAreaFromPage(EU_002_PDF, 1, new PdfRectangle(70.0, 725 - (233 - 115), 510.0, 725));
                BasicExtractionAlgorithm bea = new BasicExtractionAlgorithm();
                Table table = bea.Extract(page)[0];

                var actualArray = UtilsForTesting.TableToArrayOfRows(table);
                Assert.Equal(EU_002_EXPECTED.Length, actualArray.Length);

                for (int i = 0; i < EU_002_EXPECTED.Length; i++)
                {
                    var expecteds = EU_002_EXPECTED[i];
                    var actuals   = actualArray[i];
                    Assert.Equal(expecteds.Length, actuals.Length);
                    for (int j = 0; j < expecteds.Length; j++)
                    {
                        var e = expecteds[j];
                        var a = actuals[j];
                        Assert.Equal(e, a);
                    }
                }
            }
            else
            {
                // fails on linux and mac os. Linked to PdfPig not finding the correct font.
                // need to use apt-get -y install ttf-mscorefonts-installer
                // still have mscorefonts - eula license could not be presented
            }
        }
示例#2
0
        public void TestExtractColumnsCorrectly2()
        {
            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) // || RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
            {
                PageArea page = UtilsForTesting.GetPage(EU_017_PDF, 3);
                BasicExtractionAlgorithm bea = new BasicExtractionAlgorithm(page.VerticalRulings);
                Table table = bea.Extract(page.GetArea(new PdfRectangle(148.44, 543 - (711.875 - 299.625), 452.32, 543)))[0];

                var result = UtilsForTesting.TableToArrayOfRows(table);

                Assert.Equal(EU_017_EXPECTED.Length, result.Length);
                for (int i = 0; i < EU_017_EXPECTED.Length; i++)
                {
                    var expecteds = EU_017_EXPECTED[i];
                    var actuals   = result[i];
                    Assert.Equal(expecteds.Length, actuals.Length);
                    for (int j = 0; j < expecteds.Length; j++)
                    {
                        var e = expecteds[j];
                        var a = actuals[j];
                        Assert.Equal(e, a);
                    }
                }
            }
            else
            {
                // fails on linux and mac os. Linked to PdfPig not finding the correct font.
                // need to use apt-get -y install ttf-mscorefonts-installer
                // still have mscorefonts - eula license could not be presented
            }
        }
示例#3
0
        public void TestEmptyRegion()
        {
            PageArea page = UtilsForTesting.GetAreaFromPage("Resources/indictb1h_14.pdf", 1, new PdfRectangle(0, 700, 100.9, 800));
            BasicExtractionAlgorithm bea = new BasicExtractionAlgorithm();
            Table table = bea.Extract(page)[0];

            Assert.Equal(EXPECTED_EMPTY_TABLE, UtilsForTesting.TableToArrayOfRows(table));
        }
示例#4
0
        public void TestExtractColumnsCorrectly3()
        {
            PageArea page = UtilsForTesting.GetAreaFromFirstPage(FRX_2012_DISCLOSURE_PDF, new PdfRectangle(48.09, 563, 551.89, 685.5));
            BasicExtractionAlgorithm bea = new BasicExtractionAlgorithm();
            Table table  = bea.Extract(page)[0];
            var   result = UtilsForTesting.TableToArrayOfRows(table);

            Assert.Equal(FRX_2012_DISCLOSURE_EXPECTED.Length, result.Length);
            for (int i = 0; i < FRX_2012_DISCLOSURE_EXPECTED.Length; i++)
            {
                var expecteds = FRX_2012_DISCLOSURE_EXPECTED[i];
                var actuals   = result[i];
                Assert.Equal(expecteds.Length, actuals.Length);
                for (int j = 0; j < expecteds.Length; j++)
                {
                    var e = expecteds[j];
                    var a = actuals[j];
                    Assert.Equal(e, a);
                }
            }
        }
示例#5
0
        public void TestColumnRecognition()
        {
            PageArea page = UtilsForTesting.GetAreaFromFirstPage(ARGENTINA_DIPUTADOS_VOTING_RECORD_PDF, new PdfRectangle(12.75, 55, 557, 567));

            BasicExtractionAlgorithm bea = new BasicExtractionAlgorithm();
            Table table   = bea.Extract(page)[0];
            var   results = UtilsForTesting.TableToArrayOfRows(table);

            Assert.Equal(ARGENTINA_DIPUTADOS_VOTING_RECORD_EXPECTED.Length, results.Length);

            for (int i = 0; i < ARGENTINA_DIPUTADOS_VOTING_RECORD_EXPECTED.Length; i++)
            {
                var expected = ARGENTINA_DIPUTADOS_VOTING_RECORD_EXPECTED[i];
                var result   = results[i];
                Assert.Equal(expected.Length, result.Length);
                for (int j = 0; j < expected.Length; j++)
                {
                    var e = expected[j];
                    var r = result[j];
                    Assert.Equal(e, r);
                }
            }
        }