forked from BasicPrimitives/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShapeAnnotation.html
More file actions
116 lines (104 loc) · 4.06 KB
/
ShapeAnnotation.html
File metadata and controls
116 lines (104 loc) · 4.06 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
<!DOCTYPE html>
<html style="height: 95%">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Shape 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;
document.addEventListener('DOMContentLoaded', function () {
// create a document and pipe to a blob
var doc = new PDFDocument();
var stream = doc.pipe(blobStream());
doc.fontSize(25)
.text('Shape Annotation', 30, 30);
var sampleChart = primitives.OrgDiagramPdfkit({
items: [
/* JSON noname objects equivalent to 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 ShapeAnnotationConfig */
{
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 ShapeAnnotationConfig */
{
annotationType: primitives.AnnotationType.Shape,
items: [2,3],
label: "Cross Out",
labelSize: { width: 50, height: 50 },
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(50, 50),
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,
offset: new primitives.Thickness(20, 20, 20, 20)
})
],
cursorItem: 0,
hasSelectorCheckbox: primitives.Enabled.True,
normalItemsInterval: 40 /* defines padding around items of background annotations*/
});
var size = sampleChart.draw(doc, 30, 60);
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>