You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// we set fill color before path construction to comply with ISO 32000-2 Figure 9
128
140
doc
141
+
.save()
142
+
.fillColor('red')
129
143
.scale(0.6)
130
144
.translate(470,140)
131
145
// render an SVG path
132
146
.path('M 250,75 L 323,301 131,161 369,161 177,301 z')
133
147
// fill using the even-odd winding rule
134
-
.fill('red','even-odd')
148
+
.fill('even-odd')
135
149
.restore();
136
150
}
137
151
)
@@ -143,6 +157,7 @@ vectorSection.end();
143
157
varwrappedSection=doc.struct('Sect');
144
158
struct.add(wrappedSection);
145
159
160
+
doc.outline.addItem('PNG and JPEG images:');// add a bookmark for the wrapped text section's H1
146
161
wrappedSection.add(
147
162
doc.struct('H1',()=>{
148
163
doc
@@ -155,7 +170,7 @@ wrappedSection.add(
155
170
156
171
varloremIpsum=
157
172
'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.';
158
-
doc.text(loremIpsum,{
173
+
doc.font('Palatino').text(loremIpsum,{
159
174
width: 412,
160
175
align: 'justify',
161
176
indent: 30,
@@ -172,6 +187,7 @@ doc.addPage();
172
187
vartigerSection=doc.struct('Sect');
173
188
struct.add(tigerSection);
174
189
190
+
doc.outline.addItem('Tiger line art:');// add a bookmark for the tiger section's H1
175
191
tigerSection.add(
176
192
doc.struct('H1',()=>{
177
193
doc
@@ -185,26 +201,34 @@ tigerSection.add(
185
201
doc.struct(
186
202
'Figure',
187
203
{
188
-
alt: 'Tiger line art. '
204
+
alt: 'Tiger line art. ',
205
+
bbox: [30,140,540,680]
189
206
},
190
207
()=>{
191
208
vari,len,part;
192
209
// Render each path that makes up the tiger image
193
210
for(i=0,len=tiger.length;i<len;i++){
194
211
part=tiger[i];
195
212
doc.save();
196
-
doc.path(part.path);// render an SVG path
213
+
// we set fill color before path construction to comply with ISO 32000-2 Figure 9
214
+
if(part.fill!=='none'){
215
+
doc.fillColor(part.fill);
216
+
}
217
+
if(part.stroke!=='none'){
218
+
doc.strokeColor(part.stroke);
219
+
}
197
220
if(part['stroke-width']){
198
221
doc.lineWidth(part['stroke-width']);
199
222
}
223
+
doc.path(part.path);// render an SVG path
200
224
if(part.fill!=='none'&&part.stroke!=='none'){
201
-
doc.fillAndStroke(part.fill,part.stroke);
225
+
doc.fillAndStroke();
202
226
}else{
203
227
if(part.fill!=='none'){
204
-
doc.fill(part.fill);
228
+
doc.fill();
205
229
}
206
230
if(part.stroke!=='none'){
207
-
doc.stroke(part.stroke);
231
+
doc.stroke();
208
232
}
209
233
}
210
234
doc.restore();
@@ -222,7 +246,10 @@ doc.addPage();
222
246
varlinkSection=doc.struct('Sect');
223
247
struct.add(linkSection);
224
248
225
-
linkSection.add(
249
+
varlinkParagraph=doc.struct('P');
250
+
linkSection.add(linkParagraph);
251
+
252
+
linkParagraph.add(
226
253
doc.struct(
227
254
'Link',
228
255
{
@@ -237,6 +264,7 @@ linkSection.add(
237
264
)
238
265
);
239
266
267
+
linkParagraph.end();
240
268
linkSection.end();
241
269
242
270
// Add a list with a font loaded from a TrueType collection file
0 commit comments