1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | #include "ImageXObjectDriver.h"
|
21 | #include "PDFImageXObject.h"
|
22 | #include "ConstructorsHolder.h"
|
23 |
|
24 | using namespace v8;
|
25 |
|
26 | ImageXObjectDriver::~ImageXObjectDriver()
|
27 | {
|
28 | delete ImageXObject;
|
29 | }
|
30 |
|
31 | DEF_SUBORDINATE_INIT(ImageXObjectDriver::Init)
|
32 | {
|
33 | CREATE_ISOLATE_CONTEXT;
|
34 |
|
35 | Local<FunctionTemplate> t = NEW_FUNCTION_TEMPLATE(New);
|
36 |
|
37 | t->SetClassName(NEW_STRING("ImageXObject"));
|
38 | t->InstanceTemplate()->SetInternalFieldCount(1);
|
39 |
|
40 | SET_ACCESSOR_METHOD(t, "id", GetID);
|
41 |
|
42 |
|
43 | EXPOSE_EXTERNAL_FOR_INIT(ConstructorsHolder, holder)
|
44 | SET_CONSTRUCTOR(holder->ImageXObject_constructor, t);
|
45 | SET_CONSTRUCTOR_TEMPLATE(holder->ImageXObject_constructor_template, t);
|
46 | }
|
47 |
|
48 | ImageXObjectDriver::ImageXObjectDriver()
|
49 | {
|
50 | ImageXObject = NULL;
|
51 | }
|
52 |
|
53 | METHOD_RETURN_TYPE ImageXObjectDriver::New(const ARGS_TYPE& args)
|
54 | {
|
55 | CREATE_ISOLATE_CONTEXT;
|
56 | CREATE_ESCAPABLE_SCOPE;
|
57 |
|
58 | ImageXObjectDriver* image = new ImageXObjectDriver();
|
59 | image->Wrap(args.This());
|
60 |
|
61 | SET_FUNCTION_RETURN_VALUE(args.This())
|
62 | }
|
63 |
|
64 | METHOD_RETURN_TYPE ImageXObjectDriver::GetID(Local<String> property, const PROPERTY_TYPE &info)
|
65 | {
|
66 | CREATE_ISOLATE_CONTEXT;
|
67 | CREATE_ESCAPABLE_SCOPE;
|
68 |
|
69 | ImageXObjectDriver* image = ObjectWrap::Unwrap<ImageXObjectDriver>(info.Holder());
|
70 |
|
71 | if(!image->ImageXObject)
|
72 | {
|
73 | THROW_EXCEPTION("image object not initialized, create using pdfWriter.createFormXObject");
|
74 | SET_ACCESSOR_RETURN_VALUE(UNDEFINED)
|
75 | }
|
76 |
|
77 | SET_ACCESSOR_RETURN_VALUE(NEW_NUMBER(image->ImageXObject->GetImageObjectID()))
|
78 | }
|
79 |
|