-
-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathHighLevelContentContext.js
75 lines (67 loc) · 1.76 KB
/
HighLevelContentContext.js
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
describe("HighLevelContentContext", function () {
it("should complete without error", function () {
var pdfWriter = require("../lib/muhammara").createWriter(
__dirname + "/output/HighLevelContentContext.pdf",
);
var page = pdfWriter.createPage(0, 0, 595, 842);
var cxt = pdfWriter.startPageContentContext(page);
var textOptions = {
font: pdfWriter.getFontForFile(
__dirname + "/TestMaterials/fonts/arial.ttf",
),
size: 14,
colorspace: "gray",
color: 0x00,
underline: true,
};
var pathFillOptions = {
color: 0xff000000,
colorspace: "cmyk",
type: "fill",
};
var pathStrokeOptions = { color: "DarkMagenta", width: 4 };
// drawPath
cxt
.drawPath(
[
[75, 640],
[149, 800],
[225, 640],
],
pathFillOptions,
)
.drawPath(
75,
540,
110,
440,
149,
540,
188,
440,
223,
540,
pathStrokeOptions,
);
// drawSquare
cxt
.drawSquare(375, 640, 120, pathFillOptions)
.drawSquare(375, 440, 120, pathStrokeOptions);
// drawRectangle
cxt
.drawRectangle(375, 220, 50, 160, pathFillOptions)
.drawRectangle(375, 10, 50, 160, pathStrokeOptions);
// drawCircle
cxt
.drawCircle(149, 300, 80, pathFillOptions)
.drawCircle(149, 90, 80, pathStrokeOptions);
// writeText (writing labels for each of the shapes)
cxt
.writeText("Paths", 75, 805, textOptions)
.writeText("Squares", 375, 805, textOptions)
.writeText("Rectangles", 375, 400, textOptions)
.writeText("Circles", 75, 400, textOptions);
pdfWriter.writePage(page);
pdfWriter.end();
});
});