File tree 3 files changed +30
-4
lines changed
3 files changed +30
-4
lines changed Original file line number Diff line number Diff line change 1
- 2.0.9
1
+ 2.1.0
Original file line number Diff line number Diff line change @@ -285,11 +285,34 @@ public function getPdfSpotResources(): string
285
285
return '' ;
286
286
}
287
287
288
- $ out = '/ColorSpace << ' ;
288
+ $ out = '/ColorSpace << ' ;
289
+
289
290
foreach ($ this ->spot_colors as $ spot_color ) {
290
- $ out .= '/CS ' . $ spot_color ['i ' ] . ' ' . $ spot_color ['n ' ] . ' 0 R ' ;
291
+ $ out .= ' /CS ' . $ spot_color ['i ' ] . ' ' . $ spot_color ['n ' ] . ' 0 R ' ;
292
+ }
293
+
294
+ return $ out . ' >> ' . "\n" ;
295
+ }
296
+
297
+ /**
298
+ * Returns the PDF command to output Spot color resources.
299
+ *
300
+ * @param array<string> $keys Array of font keys.
301
+ *
302
+ * @return string PDF command
303
+ */
304
+ public function getPdfSpotResourcesByKeys (array $ keys ): string
305
+ {
306
+ if (empty ($ keys )) {
307
+ return '' ;
308
+ }
309
+
310
+ $ out = '/ColorSpace << ' ;
311
+
312
+ foreach ($ keys as $ key ) {
313
+ $ out .= ' /CS ' . $ this ->spot_colors [$ key ]['i ' ] . ' ' . $ this ->spot_colors [$ key ]['n ' ] . ' 0 R ' ;
291
314
}
292
315
293
- return $ out . ( ' >> ' . "\n" ) ;
316
+ return $ out . ' >> ' . "\n" ;
294
317
}
295
318
}
Original file line number Diff line number Diff line change @@ -170,5 +170,8 @@ public function testGetPdfSpotObjects(): void
170
170
171
171
$ res = $ spot ->getPdfSpotResources ();
172
172
$ this ->assertEquals ('/ColorSpace << /CS1 2 0 R /CS2 3 0 R /CS3 4 0 R /CS4 5 0 R /CS5 6 0 R >> ' . "\n" , $ res );
173
+
174
+ $ resk = $ spot ->getPdfSpotResourcesByKeys (['cyan ' ,'yellow ' ]);
175
+ $ this ->assertEquals ('/ColorSpace << /CS2 3 0 R /CS4 5 0 R >> ' . "\n" , $ resk );
173
176
}
174
177
}
You can’t perform that action at this time.
0 commit comments