From 2b6b38855dc832ead51fde2b29cb76ace7488aa4 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Wed, 25 Jun 2025 09:59:30 +0100 Subject: [PATCH 1/3] Add settings --- src/System.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/System.php b/src/System.php index da23025..29b5841 100644 --- a/src/System.php +++ b/src/System.php @@ -62,11 +62,15 @@ public function printers(): array })->toArray(); } - public function print(string $html, ?Printer $printer = null): void + /** + * For settings options, see https://www.electronjs.org/docs/latest/api/web-contents#contentsprintoptions-callback + */ + public function print(string $html, ?Printer $printer = null, array $settings = []): void { $this->client->post('system/print', [ 'html' => $html, 'printer' => $printer->name ?? '', + 'settings' => $settings, ]); } From f1d403b88556b1ab3a1cd911ce7581521d9517c1 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Wed, 25 Jun 2025 10:19:41 +0100 Subject: [PATCH 2/3] Allow settings on printToPDF too --- src/System.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/System.php b/src/System.php index 29b5841..d9697a4 100644 --- a/src/System.php +++ b/src/System.php @@ -65,7 +65,7 @@ public function printers(): array /** * For settings options, see https://www.electronjs.org/docs/latest/api/web-contents#contentsprintoptions-callback */ - public function print(string $html, ?Printer $printer = null, array $settings = []): void + public function print(string $html, ?Printer $printer = null, ?array $settings = []): void { $this->client->post('system/print', [ 'html' => $html, @@ -74,10 +74,11 @@ public function print(string $html, ?Printer $printer = null, array $settings = ]); } - public function printToPDF(string $html): string + public function printToPDF(string $html, ?array $settings = []): string { return $this->client->post('system/print-to-pdf', [ 'html' => $html, + 'settings' => $settings, ])->json('result'); } From cb2b4a0a1641a4436912cb777ffe0518b7a363b8 Mon Sep 17 00:00:00 2001 From: Simon Hamp Date: Wed, 25 Jun 2025 10:20:43 +0100 Subject: [PATCH 3/3] Comments --- src/System.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/System.php b/src/System.php index d9697a4..6eb2b28 100644 --- a/src/System.php +++ b/src/System.php @@ -63,7 +63,7 @@ public function printers(): array } /** - * For settings options, see https://www.electronjs.org/docs/latest/api/web-contents#contentsprintoptions-callback + * For $settings options, see https://www.electronjs.org/docs/latest/api/web-contents#contentsprintoptions-callback */ public function print(string $html, ?Printer $printer = null, ?array $settings = []): void { @@ -74,6 +74,9 @@ public function print(string $html, ?Printer $printer = null, ?array $settings = ]); } + /** + * For $settings options, see https://www.electronjs.org/docs/latest/api/web-contents#contentsprinttopdfoptions + */ public function printToPDF(string $html, ?array $settings = []): string { return $this->client->post('system/print-to-pdf', [