-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDocument.xsi
74 lines (59 loc) · 2.04 KB
/
Document.xsi
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
MODULE = Graphics::MuPDF PACKAGE = Graphics::MuPDF::Document PREFIX = Document_
PROTOTYPES: DISABLE
void Document_build_path(SV* self, Graphics__MuPDF__Context* context, const char* path)
CODE:
fz_context* ctx = context->ctx;
fz_document* doc;
MUPDF_TRY_CATCH_VOID( ctx,
doc = fz_open_document( ctx, path )
);
Graphics__MuPDF__Internal* doc_internal;
Newx(doc_internal, 1, Graphics__MuPDF__Internal);
doc_internal->kind = Document;
Newx(doc_internal->document, 1, Graphics__MuPDF__Document);
doc_internal->document->ctx = ctx;
doc_internal->document->doc = doc;
doc_internal->document->ctx_sv = SvREFCNT_inc_simple_NN(context->ctx_sv);
_mupdf_attach_mg(self, doc_internal);
void Document_DESTROY(SV* self)
CODE:
Graphics__MuPDF__Internal* internal = mupdf_get_object(self);
if( Document != internal->kind ) croak("Wrong magic: expected Document");
SvREFCNT_dec_NN(internal->document->ctx_sv);
fz_drop_document(internal->document->ctx, internal->document->doc);
Safefree(internal->document);
Safefree(internal);
int Document_count_pages(Graphics__MuPDF__Document* document)
CODE:
fz_context* ctx = document->ctx;
fz_document* doc = document->doc;
int value = -1;
MUPDF_TRY_CATCH_VOID( ctx,
value = fz_count_pages( ctx, doc );
);
RETVAL = value;
OUTPUT:
RETVAL
void Document_new_pixmap_from_page_number(Graphics__MuPDF__Document* document, \
int number, \
fz_matrix ctm, \
Graphics__MuPDF__ColorSpace* colorspace, \
int alpha, \
SV* pixmap )
CODE:
fz_context* ctx = document->ctx;
fz_document* doc = document->doc;
fz_pixmap* pix;
MUPDF_TRY_CATCH_VOID( ctx,
pix = fz_new_pixmap_from_page_number(
ctx, doc, number, ctm, colorspace->cs, alpha
)
);
Graphics__MuPDF__Internal* pix_internal;
Newx(pix_internal, 1, Graphics__MuPDF__Internal);
pix_internal->kind = Pixmap;
Newx(pix_internal->pixmap, 1, Graphics__MuPDF__Pixmap);
pix_internal->pixmap->ctx = ctx;
pix_internal->pixmap->pix = pix;
pix_internal->pixmap->ctx_sv = SvREFCNT_inc_simple_NN(document->ctx_sv);
_mupdf_attach_mg(pixmap, pix_internal);