-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMultipage.html
More file actions
290 lines (262 loc) · 11.2 KB
/
Multipage.html
File metadata and controls
290 lines (262 loc) · 11.2 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<!DOCTYPE html>
<html style="height: 95%">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Multi-page PDFKit Document Sample</title>
<script 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;
document.addEventListener('DOMContentLoaded', function () {
// create a document and pipe to a blob
// create a document and pipe to a blob
var doc = new PDFDocument();
var stream = doc.pipe(blobStream());
// draw some text
doc.fontSize(25)
.text('Some vector graphics...', 100, 30);
// some vector graphics
doc.save()
.moveTo(100, 100)
.lineTo(100, 200)
.lineTo(200, 200)
.fill("#FF3300");
doc.circle(280, 150, 50)
.fill("#6600FF");
// an SVG path
doc.scale(0.6)
.translate(470, 50)
.path('M 250,75 L 323,301 131,161 369,161 177,301 z')
.fill('red', 'even-odd')
.restore();
// draw some text
doc.fontSize(25)
.text('First Organizational Chart :-)', 100, 280);
var sampleChart = primitives.OrgDiagramPdfkit({
items: [
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
})
],
cursorItem: null,
hasSelectorCheckbox: primitives.Enabled.False
});
var size = sampleChart.draw(doc, 150, 300);
var lorem = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam in suscipit purus. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Vivamus nec hendrerit felis. Morbi aliquam facilisis risus eu lacinia. Sed eu leo in turpis fringilla hendrerit. Ut nec accumsan nisl. Suspendisse rhoncus nisl posuere tortor tempus et dapibus elit porta. Cras leo neque, elementum a rhoncus ut, vestibulum non nibh. Phasellus pretium justo turpis. Etiam vulputate, odio vitae tincidunt ultricies, eros odio dapibus nisi, ut tincidunt lacus arcu eu elit. Aenean velit erat, vehicula eget lacinia ut, dignissim non tellus. Aliquam nec lacus mi, sed vestibulum nunc. Suspendisse potenti. Curabitur vitae sem turpis. Vestibulum sed neque eget dolor dapibus porttitor at sit amet sem. Fusce a turpis lorem. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;\nMauris at ante tellus. Vestibulum a metus lectus. Praesent tempor purus a lacus blandit eget gravida ante hendrerit. Cras et eros metus. Sed commodo malesuada eros, vitae interdum augue semper quis. Fusce id magna nunc. Curabitur sollicitudin placerat semper. Cras et mi neque, a dignissim risus. Nulla venenatis porta lacus, vel rhoncus lectus tempor vitae. Duis sagittis venenatis rutrum. Curabitur tempor massa tortor.';
// and some justified text wrapped into columns
doc.fontSize(25)
.text('Some wrapped text...', 100, 300 + size.height + 10)
.font('Times-Roman', 13)
.moveDown()
.text(lorem, {
width: 412,
align: 'justify',
indent: 30,
columns: 2,
height: 120,
ellipsis: true
});
doc.addPage();
doc.fontSize(25)
.text('Annotations ...', 100, 50);
var shapeAnnotationsSample = primitives.OrgDiagramPdfkit({
cursorItem: 1,
highlightItem: 2,
hasSelectorCheckbox: primitives.Enabled.True,
selectedItems: [1, 2],
items: [
/* JSON noname objects equivalent to primitives.OrgItemConfig */
{ id: 0, parent: null, title: "James Smith", description: "VP, Public Sector", image: photos.a },
{ id: 1, parent: 0, title: "Ted Lucas", description: "VP, Human Resources", image: photos.b },
{ id: 2, parent: 0, title: "Fritz Stuger", description: "Business Solutions, US", image: photos.c },
{ id: 3, parent: 0, title: "Mike Wazowski", description: "Business Analyst, Canada", image: photos.o },
{ id: 4, parent: 3, title: "Best Friend", description: "Business Analyst, Mexico", image: photos.f }
],
annotations: [
/* JSON noname object equivalent to primitives.ConnectorAnnotationConfig */
{
annotationType: primitives.AnnotationType.Shape,
items: [0],
label: "Oval",
labelSize: new primitives.Size(50, 30),
labelPlacement: primitives.PlacementType.Right,
shapeType: primitives.ShapeType.Oval,
borderColor: primitives.Colors.Green,
offset: new primitives.Thickness(2, 2, 2, 2),
lineWidth: 2,
selectItems: true,
lineType: primitives.LineType.Dashed
},
/* JSON noname object equivalent to primitives.ConnectorAnnotationConfig */
{
annotationType: primitives.AnnotationType.Shape,
items: [2, 3],
label: "Cross Out",
labelSize: { width: 50, height: 30 },
labelPlacement: primitives.PlacementType.Right,
shapeType: primitives.ShapeType.CrossOut,
borderColor: primitives.Colors.Navy,
offset: { left: 2, top: 2, right: 2, bottom: 2 },
lineWidth: 2,
selectItems: true,
lineType: primitives.LineType.Dashed
},
/* prototype based instantiation */
new primitives.ShapeAnnotationConfig({
items: [1],
label: "Triangle",
labelSize: new primitives.Size(70, 30),
labelPlacement: primitives.PlacementType.Bottom,
shapeType: primitives.ShapeType.Triangle,
borderColor: primitives.Colors.Red,
offset: new primitives.Thickness(2, 2, 2, 2),
lineWidth: 2,
selectItems: true,
lineType: primitives.LineType.Dashed
})
,
new primitives.BackgroundAnnotationConfig({
items: [2, 3],
borderColor: "#f8e5f9",
fillColor: "#e5f9f8",
lineWidth: 2,
selectItems: true,
includeChildren: true,
lineType: primitives.LineType.Dotted
})
],
cursorItem: 0,
hasSelectorCheckbox: primitives.Enabled.True,
normalItemsInterval: 40 /* defines padding around items of background annotations*/
});
size = shapeAnnotationsSample.draw(doc, 50, 70);
var connectorAnnotationsSample = primitives.OrgDiagramPdfkit({
items: [
/* JSON noname objects equivalent to primitives.OrgItemConfig */
{ id: 0, parent: null, title: "James Smith", description: "VP, Public Sector", image: photos.a },
{ id: 1, parent: 0, title: "Ted Lucas", description: "VP, Human Resources", image: photos.b },
{ id: 2, parent: 0, title: "Fritz Stuger", description: "Business Solutions, US", image: photos.c }
],
showEndPoints: primitives.Enabled.True,
annotations: [
/* JSON noname object equivalent to primitives.ConnectorAnnotationConfig */
{
annotationType: primitives.AnnotationType.Connector,
fromItem: 0,
toItem: 2,
label: "2",
labelSize: { width: 80, height: 30 },
connectorShapeType: primitives.ConnectorShapeType.OneWay,
color: primitives.Colors.Green,
offset: 0,
lineWidth: 2,
lineType: primitives.LineType.Dashed,
selectItems: false,
showToEndpoint: primitives.Enabled.False
},
/* prototype based instantiation */
new primitives.ConnectorAnnotationConfig({
fromItem: 0,
toItem: 1,
label: "1",
labelSize: new primitives.Size(80, 30),
connectorShapeType: primitives.ConnectorShapeType.OneWay,
color: primitives.Colors.Red,
offset: 0,
lineWidth: 2,
lineType: primitives.LineType.Dashed,
selectItems: false,
showToEndpoint: primitives.Enabled.False
})
],
cursorItem: 0,
hasSelectorCheckbox: primitives.Enabled.False,
arrowsDirection: primitives.GroupByType.Parents
});
connectorAnnotationsSample.draw(doc, 150, 50 + size.height);
doc.addPage();
doc.fontSize(25)
.text('Group title sample ...', 100, 50);
var groupTitleSample = primitives.OrgDiagramPdfkit({
cursorItem: 1,
highlightItem: 2,
hasSelectorCheckbox: primitives.Enabled.True,
selectedItems: [1, 2],
items: [
new primitives.OrgItemConfig({
id: 0,
parent: null,
title: "James Smith",
description: "Parent Item",
image: photos.a
}),
new primitives.OrgItemConfig({
id: 1,
parent: 0,
itemType: primitives.ItemType.Adviser,
adviserPlacementType: primitives.AdviserPlacementType.Right,
title: "Robert Canon",
description: "Adviser item",
groupTitle: "Adviser",
image: photos.b
}),
new primitives.OrgItemConfig({
id: 2,
parent: 0,
itemType: primitives.ItemType.Assistant,
adviserPlacementType: primitives.AdviserPlacementType.Right,
title: "Ted Lucas",
description: "Assistant Item",
groupTitle: "Assistant",
image: photos.c
}),
new primitives.OrgItemConfig({
id: 3,
parent: 0,
title: "Fritz Stuger",
description: "Regular Item",
groupTitle: "Regular",
image: photos.d
})
]
});
groupTitleSample.draw(doc, 100, 100);
doc.restore();
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>