-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathannotation-example.js
78 lines (74 loc) · 2.29 KB
/
annotation-example.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
76
77
78
const fs = require('fs');
const { Container, Page, StackVertical, Text } = require('../src/components/index.js');
const { PageSize, Alignment, FontWeight } = require('../src/components/enums/index.js');
const { Offset, Border, BorderSide } = require('../src/components/models/index.js');
const ReplyPDF = require('../src/reply-pdf.js');
module.exports = {
generate: () => {
const template = new Page({
size: PageSize.A4,
margin: new Offset(50),
children: [
new StackVertical({
children: [
new Text({
margin: new Offset(10),
fontWeight: FontWeight.bold,
text: 'Go to Google',
link: 'https://www.google.com'
}),
new Text({
margin: new Offset(10),
text: 'Go to bound link',
link: '{{link}}'
}),
new Text({
margin: new Offset(10),
text: 'This is also a link',
linkStyle: {
color: 'black',
underline: false,
},
link: 'https://www.google.com'
}),
new Text({
margin: new Offset(10),
text: 'This is NOT a link',
underline: true,
color: '#1a0dab'
}),
new Container({
height: 50,
border: new Border(new BorderSide({ thickness: 1 })),
margin: new Offset(10),
link: 'https://www.google.com',
children: [
new Text({
verticalAlignment: Alignment.middle,
horizontalAlignment: Alignment.middle,
text: 'This is text surrounded by a link'
}),
],
}),
new Text({
margin: new Offset(10),
text: 'This is no longer important',
strikethrough: true,
italic: true,
}),
],
})
],
});
const data = {
link: 'https://www.google.com',
};
let doc = ReplyPDF.generateDocument({
data: data,
template: template,
debug: false,
});
doc.pipe(fs.createWriteStream('examples/outputs/output-annotation-example.pdf'));
doc.end();
}
}