File: mupdfwrap_test.cpp

package info (click to toggle)
mupdf 1.25.1%2Bds1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 21,620 kB
  • sloc: ansic: 270,929; python: 20,709; java: 6,916; javascript: 1,865; makefile: 1,130; xml: 550; sh: 430; cpp: 325; cs: 313; awk: 10; sed: 7; lisp: 3
file content (42 lines) | stat: -rw-r--r-- 1,068 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "mupdf/fitz.h"
#include "mupdf/classes.h"
#include "mupdf/classes2.h"

#include <assert.h>


int main(int argc, char** argv)
{
    assert(argc == 2);
    const char* path = argv[1];
    mupdf::FzDocument document(path);
    std::string v;
    v = mupdf::fz_lookup_metadata2(document, "format");
    printf("v=%s\n", v.c_str());
    bool raised = false;
    try
    {
        v = mupdf::fz_lookup_metadata2(document, "format___");
    }
    catch (std::exception& e)
    {
        raised = true;
        printf("Received expected exception: %s\n", e.what());
    }
    if (!raised) exit(1);
    printf("v=%s\n", v.c_str());
    fz_rect r = fz_unit_rect;
    printf("r.x0=%f\n", r.x0);

    mupdf::FzStextOptions   options;
    mupdf::FzStextPage stp( document, 0, options);
    std::vector<fz_quad>    quads = mupdf::fz_highlight_selection2(
            stp,
            mupdf::FzPoint(20, 20),
            mupdf::FzPoint(120, 220),
            100
            );
    printf("quads.size()=%zi\n", quads.size());
    assert(quads.size() == 13);
    return 0;
}