Skip to content

Commit 26d8402

Browse files
authored
Printing: Allow settings to be passed in (#634)
* Add settings * Allow settings on printToPDF too * Comments
1 parent 5df3291 commit 26d8402

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/System.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,26 @@ public function printers(): array
6262
})->toArray();
6363
}
6464

65-
public function print(string $html, ?Printer $printer = null): void
65+
/**
66+
* For $settings options, see https://www.electronjs.org/docs/latest/api/web-contents#contentsprintoptions-callback
67+
*/
68+
public function print(string $html, ?Printer $printer = null, ?array $settings = []): void
6669
{
6770
$this->client->post('system/print', [
6871
'html' => $html,
6972
'printer' => $printer->name ?? '',
73+
'settings' => $settings,
7074
]);
7175
}
7276

73-
public function printToPDF(string $html): string
77+
/**
78+
* For $settings options, see https://www.electronjs.org/docs/latest/api/web-contents#contentsprinttopdfoptions
79+
*/
80+
public function printToPDF(string $html, ?array $settings = []): string
7481
{
7582
return $this->client->post('system/print-to-pdf', [
7683
'html' => $html,
84+
'settings' => $settings,
7785
])->json('result');
7886
}
7987

0 commit comments

Comments
 (0)