forked from BasicPrimitives/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLevelAnnotation.html
More file actions
198 lines (183 loc) · 6.28 KB
/
LevelAnnotation.html
File metadata and controls
198 lines (183 loc) · 6.28 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
<html style="height: 95%">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Level Annotation PDFKit Sample</title>
<script type="text/javascript" src="../../pdfkitsamples.js"></script>
<script type="text/javascript" src="../../primitives.js"></script>
<script type='text/javascript'>
var control;
var timer = null;
var photos = pdfkitsamples.photos;
var PDFDocument = pdfkitsamples.PDFDocument;
var blobStream = pdfkitsamples.blobStream;
var annotations = [
/* JSON object equivalent to primitives.LevelAnnotationConfig */
{
annotationType: primitives.AnnotationType.Level,
levels: [0],
title: "Level 0",
titleColor: primitives.Colors.RoyalBlue,
offset: new primitives.Thickness(0, 0, 0, -1),
lineWidth: new primitives.Thickness(0, 0, 0, 1),
opacity: 0.05,
borderColor: primitives.Colors.Black,
fillColor: primitives.Colors.Yellow,
lineType: primitives.LineType.Dashed
},
new primitives.LevelAnnotationConfig({
annotationType: primitives.AnnotationType.Level,
levels: [1],
title: "Level 1",
titleColor: primitives.Colors.Green,
offset: new primitives.Thickness(0, 0, 0, -1),
lineWidth: new primitives.Thickness(0, 0, 0, 1),
opacity: 0.1,
borderColor: primitives.Colors.Black,
fillColor: primitives.Colors.Gray,
lineType: primitives.LineType.Dotted
}),
{
annotationType: primitives.AnnotationType.Level,
levels: [2],
title: "Level 2",
titleColor: primitives.Colors.Red,
offset: new primitives.Thickness(0, 0, 0, -1),
lineWidth: new primitives.Thickness(0, 0, 0, 1),
opacity: 0.05,
borderColor: primitives.Colors.Red,
fillColor: primitives.Colors.Red,
lineType: primitives.LineType.Solid
},
];
var orgItems = [
new primitives.OrgItemConfig({
id: 0,
parent: null,
title: "James Smith",
description: "VP, Public Sector",
image: photos.a
}),
new primitives.OrgItemConfig({
id: 1,
parent: 0,
title: "Ted Lucas",
description: "VP, Human Resources",
image: photos.b
}),
new primitives.OrgItemConfig({
id: 2,
parent: 0,
title: "Fritz Stuger",
description: "Business Solutions, US",
image: photos.c
}),
new primitives.OrgItemConfig({
id: 3,
parent: 2,
title: "Robert Canon",
description: "Operations, US",
image: photos.r
})
];
var famItems = [
new primitives.OrgItemConfig({
id: 0,
parents: null,
title: "James Smith",
description: "VP, Public Sector",
image: photos.a
}),
new primitives.OrgItemConfig({
id: 1,
parents: [0],
title: "Ted Lucas",
description: "VP, Human Resources",
image: photos.b
}),
new primitives.OrgItemConfig({
id: 2,
parents: [0],
title: "Fritz Stuger",
description: "Business Solutions, US",
image: photos.c
}),
new primitives.OrgItemConfig({
id: 3,
parents: [1, 2],
title: "Robert Canon",
description: "Operations, US",
image: photos.r
})
];
document.addEventListener('DOMContentLoaded', function () {
// create a document and pipe to a blob
var doc = new PDFDocument();
var stream = doc.pipe(blobStream());
for(var index = 0; index < 4; index+=1) {
var config = {
cursorItem: null,
hasSelectorCheckbox: primitives.Enabled.False,
levelTitleHorizontalAlignment: primitives.HorizontalAlignmentType.Right,
annotations: annotations
};
var label;
switch(index) {
case 0:
label = "Left, Auto";
config.orientationType = primitives.OrientationType.Left;
config.levelTitlePlacementType = primitives.AdviserPlacementType.Auto;
config.levelTitleHorizontalAlignment = primitives.HorizontalAlignmentType.Left;
break;
case 1:
label = "Top, Auto";
config.orientationType = primitives.OrientationType.Top;
config.levelTitlePlacementType = primitives.AdviserPlacementType.Auto;
config.levelTitleHorizontalAlignment = primitives.HorizontalAlignmentType.Center;
break;
case 2:
label = "Right, Auto";
config.orientationType = primitives.OrientationType.Right;
config.levelTitlePlacementType = primitives.AdviserPlacementType.Auto;
config.levelTitleHorizontalAlignment = primitives.HorizontalAlignmentType.Right;
break;
case 3:
label = "Bottom, Right";
config.orientationType = primitives.OrientationType.Bottom;
config.levelTitlePlacementType = primitives.AdviserPlacementType.Right;
config.levelTitleHorizontalAlignment = primitives.HorizontalAlignmentType.Center;
break;
}
doc.fontSize(25)
.text('Level Annotation', 30, 30);
doc.fontSize(15)
.text(label, 30, 60);
config.items = orgItems;
var sampleChart = primitives.OrgDiagramPdfkit(config);
var size = sampleChart.draw(doc, 30, 80);
doc.addPage();
doc.fontSize(25)
.text('Level Annotation', 30, 30);
doc.fontSize(15)
.text(label, 30, 60);
config.items = famItems;
var sampleChart = primitives.FamDiagramPdfkit(config);
var size = sampleChart.draw(doc, 30, 80);
doc.addPage();
}
doc.end();
stream.on('finish', function () {
var string = stream.toBlobURL('application/pdf');
document.getElementById("previewpanel").setAttribute("src", string);
});
});
</script>
</head>
<body style="height: 100%">
<div id="basicdiagram" style="width: 100%; height: 100%; border-style: none; border-width: 0px;">
<iframe id="previewpanel" type="application/pdf" width="100%" height="100%" frameborder="0"
style="position:relative;z-index:999">
</iframe>
</div>
</body>
</html>