pdfkit 0.12.2 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/examples/attachment.js +0 -42
- package/examples/attachment.pdf +0 -0
- package/examples/browserify/browser.html +0 -54
- package/examples/browserify/browser.js +0 -97
- package/examples/browserify/bundle.js +0 -91259
- package/examples/fonts/Chalkboard.ttc +0 -0
- package/examples/fonts/DejaVuSans.ttf +0 -0
- package/examples/fonts/GoodDog.ttf +0 -0
- package/examples/fonts/Helvetica.dfont +0 -0
- package/examples/fonts/Montserrat-Bold.otf +0 -0
- package/examples/fonts/PalatinoBold.ttf +0 -0
- package/examples/form.js +0 -85
- package/examples/form.pdf +0 -0
- package/examples/images/dice.png +0 -0
- package/examples/images/fish.png +0 -0
- package/examples/images/interlaced-grayscale-8bit.png +0 -0
- package/examples/images/interlaced-pallete-8bit.png +0 -0
- package/examples/images/interlaced-rgb-16bit.png +0 -0
- package/examples/images/interlaced-rgb-8bit.png +0 -0
- package/examples/images/interlaced-rgb-alpha-8bit.png +0 -0
- package/examples/images/pngsuite-gray-transparent-white.png +0 -0
- package/examples/images/pngsuite-rgb-transparent-white.png +0 -0
- package/examples/images/straight.png +0 -0
- package/examples/images/test.jpeg +0 -0
- package/examples/images/test.png +0 -0
- package/examples/images/test2.png +0 -0
- package/examples/images/test3.png +0 -0
- package/examples/kitchen-sink-accessible.js +0 -255
- package/examples/kitchen-sink-accessible.pdf +0 -0
- package/examples/kitchen-sink.js +0 -115
- package/examples/kitchen-sink.pdf +0 -0
- package/examples/text-link.js +0 -26
- package/examples/text-link.pdf +0 -0
- package/examples/tiger.js +0 -1742
- package/examples/webpack/README.md +0 -14
- package/examples/webpack/package.json +0 -21
- package/examples/webpack/webpack.config.js +0 -84
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/examples/form.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
var PDFDocument = require('../');
|
|
2
|
-
var fs = require('fs');
|
|
3
|
-
|
|
4
|
-
// Create a new PDFDocument
|
|
5
|
-
var doc = new PDFDocument();
|
|
6
|
-
|
|
7
|
-
doc.pipe(fs.createWriteStream('form.pdf'));
|
|
8
|
-
|
|
9
|
-
// Set some meta data
|
|
10
|
-
doc.info['Title'] = 'Test Form Document';
|
|
11
|
-
doc.info['Author'] = 'test-acroform.js';
|
|
12
|
-
|
|
13
|
-
doc.font('Helvetica'); // establishes the default font for forms
|
|
14
|
-
doc.initForm();
|
|
15
|
-
|
|
16
|
-
let rootField = doc.formField('rootField');
|
|
17
|
-
doc.font('Courier');
|
|
18
|
-
let child1Field = doc.formField('child1Field', { parent: rootField });
|
|
19
|
-
doc.font('Helvetica');
|
|
20
|
-
let child2Field = doc.formField('child2Field', { parent: rootField });
|
|
21
|
-
|
|
22
|
-
let y = 10;
|
|
23
|
-
doc.formText('leaf1', 10, y, 200, 20, {
|
|
24
|
-
parent: child1Field,
|
|
25
|
-
value: '1999-12-31',
|
|
26
|
-
format: {
|
|
27
|
-
type: 'date',
|
|
28
|
-
param: 'yyyy-mm-dd'
|
|
29
|
-
},
|
|
30
|
-
align: 'center'
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
y += 30;
|
|
34
|
-
opts = {
|
|
35
|
-
parent: child1Field,
|
|
36
|
-
value: 32.98,
|
|
37
|
-
format: {
|
|
38
|
-
type: 'number',
|
|
39
|
-
nDec: 2,
|
|
40
|
-
currency: '$',
|
|
41
|
-
currencyPrepend: true
|
|
42
|
-
},
|
|
43
|
-
align: 'right'
|
|
44
|
-
};
|
|
45
|
-
doc.formText('dollar', 10, y, 200, 20, opts);
|
|
46
|
-
|
|
47
|
-
y += 30;
|
|
48
|
-
doc.formText('leaf2', 10, y, 200, 40, {
|
|
49
|
-
parent: child1Field,
|
|
50
|
-
multiline: true,
|
|
51
|
-
align: 'right'
|
|
52
|
-
});
|
|
53
|
-
y += 50;
|
|
54
|
-
doc.formText('leaf3', 10, y, 200, 80, {
|
|
55
|
-
parent: child2Field,
|
|
56
|
-
multiline: true
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
y += 90;
|
|
60
|
-
var opts = {
|
|
61
|
-
backgroundColor: 'yellow',
|
|
62
|
-
label: 'Test Button'
|
|
63
|
-
};
|
|
64
|
-
doc.formPushButton('btn1', 10, y, 100, 30, opts);
|
|
65
|
-
|
|
66
|
-
y += 40;
|
|
67
|
-
opts = {
|
|
68
|
-
borderColor: 'black',
|
|
69
|
-
select: ['Select Option', 'github', 'bitbucket', 'gitlab'],
|
|
70
|
-
value: 'Select Option',
|
|
71
|
-
defaultValue: 'Select Option',
|
|
72
|
-
align: 'center',
|
|
73
|
-
edit: true
|
|
74
|
-
};
|
|
75
|
-
doc.formCombo('ch1', 10, y, 100, 20, opts);
|
|
76
|
-
|
|
77
|
-
y += 30;
|
|
78
|
-
opts = {
|
|
79
|
-
borderColor: '#808080',
|
|
80
|
-
select: ['github', 'bitbucket', 'gitlab', 'sourcesafe', 'perforce'],
|
|
81
|
-
sort: true
|
|
82
|
-
};
|
|
83
|
-
doc.formList('ch2', 10, y, 100, 45, opts);
|
|
84
|
-
|
|
85
|
-
doc.end();
|
package/examples/form.pdf
DELETED
|
Binary file
|
package/examples/images/dice.png
DELETED
|
Binary file
|
package/examples/images/fish.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/examples/images/test.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
var PDFDocument = require('../');
|
|
2
|
-
var tiger = require('./tiger');
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
|
|
5
|
-
// Create a new PDFDocument
|
|
6
|
-
var doc = new PDFDocument({
|
|
7
|
-
pdfVersion: '1.5',
|
|
8
|
-
lang: 'en-US',
|
|
9
|
-
tagged: true,
|
|
10
|
-
displayTitle: true
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
doc.pipe(fs.createWriteStream('kitchen-sink-accessible.pdf'));
|
|
14
|
-
|
|
15
|
-
// Set some meta data
|
|
16
|
-
doc.info['Title'] = 'Test Document';
|
|
17
|
-
doc.info['Author'] = 'Devon Govett';
|
|
18
|
-
|
|
19
|
-
// Initialise document logical structure
|
|
20
|
-
var struct = doc.struct('Document');
|
|
21
|
-
doc.addStructure(struct);
|
|
22
|
-
|
|
23
|
-
// Register a font name for use later
|
|
24
|
-
doc.registerFont('Palatino', 'fonts/PalatinoBold.ttf');
|
|
25
|
-
|
|
26
|
-
// Set the font and draw some text
|
|
27
|
-
struct.add(
|
|
28
|
-
doc.struct('P', () => {
|
|
29
|
-
doc
|
|
30
|
-
.font('Palatino')
|
|
31
|
-
.fontSize(25)
|
|
32
|
-
.text('Some text with an embedded font! ', 100, 100);
|
|
33
|
-
})
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
// Embed some images
|
|
37
|
-
var imageSection = doc.struct('Sect');
|
|
38
|
-
struct.add(imageSection);
|
|
39
|
-
|
|
40
|
-
imageSection.add(
|
|
41
|
-
doc.struct('H1', () => {
|
|
42
|
-
doc.fontSize(18).text('PNG and JPEG images: ');
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
imageSection.add(
|
|
47
|
-
doc.struct(
|
|
48
|
-
'Figure',
|
|
49
|
-
{
|
|
50
|
-
alt: 'Promotional image of an Apple laptop. '
|
|
51
|
-
},
|
|
52
|
-
() => {
|
|
53
|
-
doc.image('images/test.png', 100, 160, {
|
|
54
|
-
width: 412
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
)
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
imageSection.add(
|
|
61
|
-
doc.struct(
|
|
62
|
-
'Figure',
|
|
63
|
-
{
|
|
64
|
-
alt:
|
|
65
|
-
'Photograph of a path flanked by blossoming trees with surrounding hedges. '
|
|
66
|
-
},
|
|
67
|
-
() => {
|
|
68
|
-
doc.image('images/test.jpeg', 190, 400, {
|
|
69
|
-
height: 300
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
imageSection.end();
|
|
76
|
-
|
|
77
|
-
// Add another page
|
|
78
|
-
doc.addPage();
|
|
79
|
-
|
|
80
|
-
// Draw a triangle, a circle and a star
|
|
81
|
-
var vectorSection = doc.struct('Sect');
|
|
82
|
-
struct.add(vectorSection);
|
|
83
|
-
|
|
84
|
-
vectorSection.add(
|
|
85
|
-
doc.struct('H1', () => {
|
|
86
|
-
doc.fontSize(25).text('Here are some vector graphics... ', 100, 100);
|
|
87
|
-
})
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
vectorSection.add(
|
|
91
|
-
doc.struct(
|
|
92
|
-
'Figure',
|
|
93
|
-
{
|
|
94
|
-
alt: 'Orange triangle. '
|
|
95
|
-
},
|
|
96
|
-
() => {
|
|
97
|
-
doc
|
|
98
|
-
.save()
|
|
99
|
-
.moveTo(100, 150)
|
|
100
|
-
.lineTo(100, 250)
|
|
101
|
-
.lineTo(200, 250)
|
|
102
|
-
.fill('#FF8800');
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
vectorSection.add(
|
|
108
|
-
doc.struct(
|
|
109
|
-
'Figure',
|
|
110
|
-
{
|
|
111
|
-
alt: 'Purple circle. '
|
|
112
|
-
},
|
|
113
|
-
() => {
|
|
114
|
-
doc.circle(280, 200, 50).fill('#7722FF');
|
|
115
|
-
}
|
|
116
|
-
)
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
vectorSection.add(
|
|
120
|
-
doc.struct(
|
|
121
|
-
'Figure',
|
|
122
|
-
{
|
|
123
|
-
alt: 'Red star with hollow center. '
|
|
124
|
-
},
|
|
125
|
-
() => {
|
|
126
|
-
doc
|
|
127
|
-
.scale(0.6)
|
|
128
|
-
.translate(470, 140)
|
|
129
|
-
// render an SVG path
|
|
130
|
-
.path('M 250,75 L 323,301 131,161 369,161 177,301 z')
|
|
131
|
-
// fill using the even-odd winding rule
|
|
132
|
-
.fill('red', 'even-odd')
|
|
133
|
-
.restore();
|
|
134
|
-
}
|
|
135
|
-
)
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
vectorSection.end();
|
|
139
|
-
|
|
140
|
-
// Draw some text wrapped to 412 points wide, split into paragraphs
|
|
141
|
-
var wrappedSection = doc.struct('Sect');
|
|
142
|
-
struct.add(wrappedSection);
|
|
143
|
-
|
|
144
|
-
wrappedSection.add(
|
|
145
|
-
doc.struct('H1', () => {
|
|
146
|
-
doc
|
|
147
|
-
.text('And here is some wrapped text... ', 100, 300)
|
|
148
|
-
.font('Helvetica', 13)
|
|
149
|
-
// move down 1 line
|
|
150
|
-
.moveDown();
|
|
151
|
-
})
|
|
152
|
-
);
|
|
153
|
-
|
|
154
|
-
var loremIpsum =
|
|
155
|
-
'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.';
|
|
156
|
-
doc.text(loremIpsum, {
|
|
157
|
-
width: 412,
|
|
158
|
-
align: 'justify',
|
|
159
|
-
indent: 30,
|
|
160
|
-
paragraphGap: 5,
|
|
161
|
-
structParent: wrappedSection
|
|
162
|
-
});
|
|
163
|
-
|
|
164
|
-
wrappedSection.end();
|
|
165
|
-
|
|
166
|
-
// Add another page
|
|
167
|
-
doc.addPage();
|
|
168
|
-
|
|
169
|
-
// Set the font back and draw tiger line art based on an SVG
|
|
170
|
-
var tigerSection = doc.struct('Sect');
|
|
171
|
-
struct.add(tigerSection);
|
|
172
|
-
|
|
173
|
-
tigerSection.add(
|
|
174
|
-
doc.struct('H1', () => {
|
|
175
|
-
doc
|
|
176
|
-
.font('Palatino', 25)
|
|
177
|
-
.text('Rendering some SVG paths...', 100, 100)
|
|
178
|
-
.translate(220, 300);
|
|
179
|
-
})
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
tigerSection.add(
|
|
183
|
-
doc.struct(
|
|
184
|
-
'Figure',
|
|
185
|
-
{
|
|
186
|
-
alt: 'Tiger line art. '
|
|
187
|
-
},
|
|
188
|
-
() => {
|
|
189
|
-
var i, len, part;
|
|
190
|
-
// Render each path that makes up the tiger image
|
|
191
|
-
for (i = 0, len = tiger.length; i < len; i++) {
|
|
192
|
-
part = tiger[i];
|
|
193
|
-
doc.save();
|
|
194
|
-
doc.path(part.path); // render an SVG path
|
|
195
|
-
if (part['stroke-width']) {
|
|
196
|
-
doc.lineWidth(part['stroke-width']);
|
|
197
|
-
}
|
|
198
|
-
if (part.fill !== 'none' && part.stroke !== 'none') {
|
|
199
|
-
doc.fillAndStroke(part.fill, part.stroke);
|
|
200
|
-
} else {
|
|
201
|
-
if (part.fill !== 'none') {
|
|
202
|
-
doc.fill(part.fill);
|
|
203
|
-
}
|
|
204
|
-
if (part.stroke !== 'none') {
|
|
205
|
-
doc.stroke(part.stroke);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
doc.restore();
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
)
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
tigerSection.end();
|
|
215
|
-
|
|
216
|
-
// Add another page
|
|
217
|
-
doc.addPage();
|
|
218
|
-
|
|
219
|
-
// Add some text with annotations
|
|
220
|
-
var linkSection = doc.struct('Sect');
|
|
221
|
-
struct.add(linkSection);
|
|
222
|
-
|
|
223
|
-
linkSection.add(
|
|
224
|
-
doc.struct(
|
|
225
|
-
'Link',
|
|
226
|
-
{
|
|
227
|
-
alt: 'Here is a link! '
|
|
228
|
-
},
|
|
229
|
-
() => {
|
|
230
|
-
doc.fillColor('blue').text('Here is a link!', 100, 100, {
|
|
231
|
-
link: 'http://google.com/',
|
|
232
|
-
underline: true
|
|
233
|
-
});
|
|
234
|
-
}
|
|
235
|
-
)
|
|
236
|
-
);
|
|
237
|
-
|
|
238
|
-
linkSection.end();
|
|
239
|
-
|
|
240
|
-
// Add a list with a font loaded from a TrueType collection file
|
|
241
|
-
var listSection = doc.struct('Sect');
|
|
242
|
-
struct.add(listSection);
|
|
243
|
-
|
|
244
|
-
var list = doc.struct('L');
|
|
245
|
-
listSection.add(list);
|
|
246
|
-
|
|
247
|
-
doc
|
|
248
|
-
.fillColor('#000')
|
|
249
|
-
.font('fonts/Chalkboard.ttc', 'Chalkboard', 16)
|
|
250
|
-
.list(['One, ', 'Two, ', 'Three. '], 100, 150, { structParent: list });
|
|
251
|
-
|
|
252
|
-
listSection.end(); // This recursively ends the list as well
|
|
253
|
-
|
|
254
|
-
// End and flush the document
|
|
255
|
-
doc.end();
|
|
Binary file
|
package/examples/kitchen-sink.js
DELETED
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
var PDFDocument = require('../js/pdfkit');
|
|
2
|
-
var tiger = require('./tiger');
|
|
3
|
-
var fs = require('fs');
|
|
4
|
-
|
|
5
|
-
// Create a new PDFDocument
|
|
6
|
-
var doc = new PDFDocument();
|
|
7
|
-
|
|
8
|
-
doc.pipe(fs.createWriteStream('kitchen-sink.pdf'));
|
|
9
|
-
|
|
10
|
-
// Set some meta data
|
|
11
|
-
doc.info['Title'] = 'Test Document';
|
|
12
|
-
|
|
13
|
-
doc.info['Author'] = 'Devon Govett';
|
|
14
|
-
|
|
15
|
-
// Register a font name for use later
|
|
16
|
-
doc.registerFont('Palatino', 'fonts/PalatinoBold.ttf');
|
|
17
|
-
|
|
18
|
-
// Set the font, draw some text, and embed an image
|
|
19
|
-
doc
|
|
20
|
-
.font('Palatino')
|
|
21
|
-
.fontSize(25)
|
|
22
|
-
.text('Some text with an embedded font!', 100, 100)
|
|
23
|
-
.fontSize(18)
|
|
24
|
-
.text('PNG and JPEG images:')
|
|
25
|
-
.image('images/test.png', 100, 160, {
|
|
26
|
-
width: 412
|
|
27
|
-
})
|
|
28
|
-
.image('images/test.jpeg', 190, 400, {
|
|
29
|
-
height: 300
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Add another page
|
|
33
|
-
doc
|
|
34
|
-
.addPage()
|
|
35
|
-
.fontSize(25)
|
|
36
|
-
.text('Here is some vector graphics...', 100, 100);
|
|
37
|
-
|
|
38
|
-
// Draw a triangle and a circle
|
|
39
|
-
doc
|
|
40
|
-
.save()
|
|
41
|
-
.moveTo(100, 150)
|
|
42
|
-
.lineTo(100, 250)
|
|
43
|
-
.lineTo(200, 250)
|
|
44
|
-
.fill('#FF3300');
|
|
45
|
-
|
|
46
|
-
doc.circle(280, 200, 50).fill('#6600FF');
|
|
47
|
-
|
|
48
|
-
doc
|
|
49
|
-
.scale(0.6)
|
|
50
|
-
.translate(470, -380)
|
|
51
|
-
.path('M 250,75 L 323,301 131,161 369,161 177,301 z')
|
|
52
|
-
.fill('red', 'even-odd')
|
|
53
|
-
.restore(); // render an SVG path // fill using the even-odd winding rule
|
|
54
|
-
|
|
55
|
-
var loremIpsum =
|
|
56
|
-
'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.';
|
|
57
|
-
|
|
58
|
-
// Draw some text wrapped to 412 points wide
|
|
59
|
-
doc
|
|
60
|
-
.text('And here is some wrapped text...', 100, 300)
|
|
61
|
-
.font('Helvetica', 13)
|
|
62
|
-
.moveDown()
|
|
63
|
-
.text(loremIpsum, {
|
|
64
|
-
// move down 1 line
|
|
65
|
-
width: 412,
|
|
66
|
-
align: 'justify',
|
|
67
|
-
indent: 30,
|
|
68
|
-
paragraphGap: 5
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
// Add another page, and set the font back
|
|
72
|
-
doc
|
|
73
|
-
.addPage()
|
|
74
|
-
.font('Palatino', 25)
|
|
75
|
-
.text('Rendering some SVG paths...', 100, 100)
|
|
76
|
-
.translate(220, 300);
|
|
77
|
-
|
|
78
|
-
var i, len, part;
|
|
79
|
-
// Render each path that makes up the tiger image
|
|
80
|
-
for (i = 0, len = tiger.length; i < len; i++) {
|
|
81
|
-
part = tiger[i];
|
|
82
|
-
doc.save();
|
|
83
|
-
doc.path(part.path); // render an SVG path
|
|
84
|
-
if (part['stroke-width']) {
|
|
85
|
-
doc.lineWidth(part['stroke-width']);
|
|
86
|
-
}
|
|
87
|
-
if (part.fill !== 'none' && part.stroke !== 'none') {
|
|
88
|
-
doc.fillAndStroke(part.fill, part.stroke);
|
|
89
|
-
} else {
|
|
90
|
-
if (part.fill !== 'none') {
|
|
91
|
-
doc.fill(part.fill);
|
|
92
|
-
}
|
|
93
|
-
if (part.stroke !== 'none') {
|
|
94
|
-
doc.stroke(part.stroke);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
doc.restore();
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Add some text with annotations
|
|
101
|
-
doc
|
|
102
|
-
.addPage()
|
|
103
|
-
.fillColor('blue')
|
|
104
|
-
.text('Here is a link!', 100, 100, {
|
|
105
|
-
link: 'http://google.com/',
|
|
106
|
-
underline: true
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
// Add a list with a font loaded from a TrueType collection file
|
|
110
|
-
doc
|
|
111
|
-
.fillColor('#000')
|
|
112
|
-
.font('fonts/Chalkboard.ttc', 'Chalkboard', 16)
|
|
113
|
-
.list(['One', 'Two', 'Three'], 100, 150);
|
|
114
|
-
|
|
115
|
-
doc.end();
|
|
Binary file
|
package/examples/text-link.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
var fs = require('fs');
|
|
2
|
-
var PDFDocument = require('../');
|
|
3
|
-
|
|
4
|
-
var doc = new PDFDocument({ bufferPages: true });
|
|
5
|
-
doc.pipe(fs.createWriteStream('text-link.pdf'));
|
|
6
|
-
doc.addPage();
|
|
7
|
-
doc.addPage();
|
|
8
|
-
doc.switchToPage(0);
|
|
9
|
-
doc.text('First Page', { paragraphGap: 4 });
|
|
10
|
-
doc.text('Click here to go to Second Page', { link: 1, paragraphGap: 4 });
|
|
11
|
-
doc
|
|
12
|
-
.text('Continued text ', { continued: true })
|
|
13
|
-
.text('with a link inside', {
|
|
14
|
-
continued: true,
|
|
15
|
-
link: 'http://pdfkit.org',
|
|
16
|
-
underline: true
|
|
17
|
-
})
|
|
18
|
-
.text(' and remaining text', {
|
|
19
|
-
continued: false,
|
|
20
|
-
link: null,
|
|
21
|
-
underline: false
|
|
22
|
-
});
|
|
23
|
-
doc.switchToPage(1);
|
|
24
|
-
doc.text('Go To First Page', { link: 0 });
|
|
25
|
-
doc.text('Link to google', { link: 'https://www.google.com/' });
|
|
26
|
-
doc.end();
|
package/examples/text-link.pdf
DELETED
|
Binary file
|