Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
7640 views
1
#include "common.h"
2
#include "mupdf/pdf.h"
3
#import "MuDocRef.h"
4
5
@implementation MuDocRef
6
7
-(id) initWithFilename:(char *)aFilename;
8
{
9
self = [super init];
10
if (self)
11
{
12
dispatch_sync(queue, ^{});
13
14
fz_var(self);
15
16
fz_try(ctx)
17
{
18
doc = fz_open_document(ctx, aFilename);
19
if (!doc)
20
{
21
[self release];
22
self = nil;
23
}
24
else
25
{
26
pdf_document *idoc = pdf_specifics(ctx, doc);
27
if (idoc) pdf_enable_js(ctx, idoc);
28
interactive = (idoc != NULL) && (pdf_crypt_version(ctx, idoc) == 0);
29
}
30
}
31
fz_catch(ctx)
32
{
33
if (self)
34
{
35
if (doc != NULL)
36
fz_drop_document(ctx, doc);
37
[self release];
38
self = nil;
39
}
40
}
41
}
42
return self;
43
}
44
45
-(void) dealloc
46
{
47
__block fz_document *block_doc = doc;
48
dispatch_async(queue, ^{
49
fz_drop_document(ctx, block_doc);
50
});
51
[super dealloc];
52
}
53
54
@end
55
56