1717 * @param int[] $failOnHttpStatusCodes
1818 * @param int[] $failOnResourceHttpStatusCodes
1919 * @param array<string,string|bool|float|int|array<string>> $metadata
20+ * @param Stream[] $embeds
2021 * @param Stream[] $assets
2122 */
2223 function (
@@ -56,6 +57,7 @@ function (
5657 bool $ flatten = false ,
5758 string $ userPassword = '' ,
5859 string $ ownerPassword = '' ,
60+ array $ embeds = [],
5961 array $ assets = [],
6062 ): void {
6163 $ chromium = Gotenberg::chromium ('' )->pdf ();
@@ -96,6 +98,7 @@ function (
9698 $ flatten ,
9799 $ userPassword ,
98100 $ ownerPassword ,
101+ $ embeds ,
99102 $ assets ,
100103 );
101104
@@ -142,6 +145,7 @@ function (
142145 $ flatten ,
143146 $ userPassword ,
144147 $ ownerPassword ,
148+ $ embeds ,
145149 $ assets ,
146150 );
147151 },
@@ -191,6 +195,10 @@ function (
191195 true ,
192196 'my_user_password ' ,
193197 'my_owner_password ' ,
198+ [
199+ Stream::string ('my.xml ' , 'XML content ' ),
200+ Stream::string ('my_second.xml ' , 'Second XML content ' ),
201+ ],
194202 [
195203 Stream::string ('my.jpg ' , 'Image content ' ),
196204 ],
@@ -205,6 +213,7 @@ function (
205213 * @param int[] $failOnHttpStatusCodes
206214 * @param int[] $failOnResourceHttpStatusCodes
207215 * @param array<string,string|bool|float|int|array<string>> $metadata
216+ * @param Stream[] $embeds
208217 * @param Stream[] $assets
209218 */
210219 function (
@@ -244,6 +253,7 @@ function (
244253 bool $ flatten = false ,
245254 string $ userPassword = '' ,
246255 string $ ownerPassword = '' ,
256+ array $ embeds = [],
247257 array $ assets = [],
248258 ): void {
249259 $ chromium = Gotenberg::chromium ('' )->pdf ();
@@ -284,6 +294,7 @@ function (
284294 $ flatten ,
285295 $ userPassword ,
286296 $ ownerPassword ,
297+ $ embeds ,
287298 $ assets ,
288299 );
289300
@@ -332,6 +343,7 @@ function (
332343 $ flatten ,
333344 $ userPassword ,
334345 $ ownerPassword ,
346+ $ embeds ,
335347 $ assets ,
336348 );
337349 },
@@ -380,6 +392,10 @@ function (
380392 true ,
381393 'my_user_password ' ,
382394 'my_owner_password ' ,
395+ [
396+ Stream::string ('my.xml ' , 'XML content ' ),
397+ Stream::string ('my_second.xml ' , 'Second XML content ' ),
398+ ],
383399 [
384400 Stream::string ('my.jpg ' , 'Image content ' ),
385401 ],
@@ -395,6 +411,7 @@ function (
395411 * @param int[] $failOnResourceHttpStatusCodes
396412 * @param Stream[] $markdowns
397413 * @param array<string,string|bool|float|int|array<string>> $metadata
414+ * @param Stream[] $embeds
398415 * @param Stream[] $assets
399416 */
400417 function (
@@ -435,6 +452,7 @@ function (
435452 bool $ flatten = false ,
436453 string $ userPassword = '' ,
437454 string $ ownerPassword = '' ,
455+ array $ embeds = [],
438456 array $ assets = [],
439457 ): void {
440458 $ chromium = Gotenberg::chromium ('' )->pdf ();
@@ -475,6 +493,7 @@ function (
475493 $ flatten ,
476494 $ userPassword ,
477495 $ ownerPassword ,
496+ $ embeds ,
478497 $ assets ,
479498 );
480499
@@ -528,6 +547,7 @@ function (
528547 $ flatten ,
529548 $ userPassword ,
530549 $ ownerPassword ,
550+ $ embeds ,
531551 $ assets ,
532552 );
533553 },
@@ -585,6 +605,10 @@ function (
585605 true ,
586606 'my_user_password ' ,
587607 'my_owner_password ' ,
608+ [
609+ Stream::string ('my.xml ' , 'XML content ' ),
610+ Stream::string ('my_second.xml ' , 'Second XML content ' ),
611+ ],
588612 [
589613 Stream::string ('my.jpg ' , 'Image content ' ),
590614 ],
@@ -597,6 +621,7 @@ function (
597621 * @param int[] $failOnHttpStatusCodes
598622 * @param int[] $failOnResourceHttpStatusCodes
599623 * @param array<string,string|bool|float|int|array<string>> $metadata
624+ * @param Stream[] $embeds
600625 * @param Stream[] $assets
601626 */
602627function hydrateChromiumPdfFormData (
@@ -636,6 +661,7 @@ function hydrateChromiumPdfFormData(
636661 bool $ flatten = false ,
637662 string $ userPassword = '' ,
638663 string $ ownerPassword = '' ,
664+ array $ embeds = [],
639665 array $ assets = [],
640666): ChromiumPdf {
641667 if ($ singlePage ) {
@@ -762,6 +788,10 @@ function hydrateChromiumPdfFormData(
762788 $ chromium ->encrypt ($ userPassword , $ ownerPassword );
763789 }
764790
791+ if (count ($ embeds ) > 0 ) {
792+ $ chromium ->embeds (...$ embeds );
793+ }
794+
765795 if (count ($ assets ) > 0 ) {
766796 $ chromium ->assets (...$ assets );
767797 }
@@ -775,6 +805,7 @@ function hydrateChromiumPdfFormData(
775805 * @param int[] $failOnHttpStatusCodes
776806 * @param int[] $failOnResourceHttpStatusCodes
777807 * @param array<string,string|bool|float|int|array<string>> $metadata
808+ * @param Stream[] $embeds
778809 * @param Stream[] $assets
779810 */
780811function expectChromiumPdfOptions (
@@ -814,6 +845,7 @@ function expectChromiumPdfOptions(
814845 bool $ flatten ,
815846 string $ userPassword ,
816847 string $ ownerPassword ,
848+ array $ embeds ,
817849 array $ assets ,
818850): void {
819851 expect ($ body )->unless ($ singlePage === false , fn ($ body ) => $ body ->toContainFormValue ('singlePage ' , '1 ' ));
@@ -919,6 +951,11 @@ function expectChromiumPdfOptions(
919951 expect ($ body )->unless ($ userPassword === '' , fn ($ body ) => $ body ->toContainFormValue ('userPassword ' , $ userPassword ));
920952 expect ($ body )->unless ($ userPassword === '' , fn ($ body ) => $ body ->toContainFormValue ('ownerPassword ' , $ ownerPassword ));
921953
954+ foreach ($ embeds as $ embed ) {
955+ $ embed ->getStream ()->rewind ();
956+ expect ($ body )->toContainFormFile ($ embed ->getFilename (), $ embed ->getStream ()->getContents (), 'application/xml ' , 'embeds ' );
957+ }
958+
922959 if (count ($ assets ) <= 0 ) {
923960 return ;
924961 }
0 commit comments