Debian Codegraph @

podofo/test/unit/TextExtraction.cpp

raw symbols SCIP
1 /**
2 * Copyright (C) 2008 by Dominik Seichter <[email protected]>
3 * Copyright (C) 2021 by Francesco Pretto <[email protected]>
4 *
5 * Licensed under GNU Library General Public 2.0 or later.
6 * Some rights reserved. See COPYING, AUTHORS.
7 */
8
9 #include <PdfTest.h>
10
11 using namespace std;
12 using namespace PoDoFo;
13
14 TEST_CASE("TextExtraction1")
15 {
16 PdfMemDocument doc;
17 doc.Load(TestUtils::GetTestInputFilePath("TextExtraction1.pdf"));
18 auto& page = doc.GetPages().GetPageAt(0);
19 vector<PdfTextEntry> entries;
20 page.ExtractTextTo(entries);
21
22 REQUIRE(entries[0].Text == "MATLAB (an abbreviation of \"matrix laboratory\") is a proprietary multi-paradigm programming");
23 ASSERT_EQUAL(entries[0].X, 29.000000232);
24 ASSERT_EQUAL(entries[0].Y, 694.943905559551);
25 REQUIRE(entries[1].Text == "language and numerical computing environment developed by MathWorks. MATLAB allows matrix");
26 ASSERT_EQUAL(entries[1].X, 29.000000232);
27 ASSERT_EQUAL(entries[1].Y, 684.920205479362);
28 REQUIRE(entries[2].Text == "manipulations, plotting of functions and data, implementation of algorithms, creation of user");
29 ASSERT_EQUAL(entries[2].X, 28.977805831822455);
30 ASSERT_EQUAL(entries[2].Y, 674.89580539916642);
31 REQUIRE(entries[3].Text == "interfaces, and interfacing with programs written in other languages.");
32 ASSERT_EQUAL(entries[3].X, 29.000000232);
33 ASSERT_EQUAL(entries[3].Y, 664.872605318981);
34 }
35
36 TEST_CASE("TextExtraction2")
37 {
38 // Extraction with inline fonts
39 PdfMemDocument doc;
40 doc.Load(TestUtils::GetTestInputFilePath("TextExtraction2.pdf"));
41 auto& page = doc.GetPages().GetPageAt(0);
42 vector<PdfTextEntry> entries;
43 page.ExtractTextTo(entries);
44 REQUIRE(entries[0].Text == "Test text");
45 ASSERT_EQUAL(entries[0].X, 31.199999999999999);
46 ASSERT_EQUAL(entries[0].Y, 801.60000000000002);
47 }