Skip to content

Commit b1db41c

Browse files
committed
add printer settings to docs
1 parent cc081fd commit b1db41c

File tree

1 file changed

+38
-2
lines changed
  • resources/views/docs/desktop/1/the-basics

1 file changed

+38
-2
lines changed

resources/views/docs/desktop/1/the-basics/system.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ System::print('<html>...', $printer);
111111

112112
If no `$printer` object is provided, the default printer and settings will be used.
113113

114+
You can also print directly to PDF:
115+
116+
```php
117+
System::printToPDF('<html>...');
118+
```
119+
120+
### Print Settings
121+
114122
You can change the configuration before sending something to be printed, for example if you want multiple copies:
115123

116124
```php
@@ -119,12 +127,40 @@ $printer->options['copies'] = 5;
119127
System::print('<html>...', $printer);
120128
```
121129

122-
You can also print directly to PDF:
130+
Additionally, both the `print()` and `printToPDF()` methods accept an optional `$settings` parameter that allows you to customize the print behavior:
123131

124132
```php
125-
System::printToPDF('<html>...');
133+
System::print('<html>...', $printer, $settings);
126134
```
127135

136+
#### Print Settings Examples
137+
138+
You can customize print behavior using the settings array. Here are some common examples:
139+
140+
```php
141+
// Print with custom page size and orientation
142+
$settings = [
143+
'pageSize' => 'A4',
144+
'landscape' => true,
145+
'marginsType' => 1, // 0: default, 1: none, 2: minimum
146+
];
147+
148+
System::print('<html>...', $printer, $settings);
149+
```
150+
151+
```php
152+
// Print multiple copies with duplex
153+
$settings = [
154+
'copies' => 3,
155+
'duplex' => 'long', // 'simplex', 'short', 'long'
156+
'color' => false, // true for color, false for monochrome
157+
];
158+
159+
System::print('<html>...', $printer, $settings);
160+
```
161+
162+
For a complete list of available print settings, refer to the [Electron webContents.print()](https://www.electronjs.org/docs/latest/api/web-contents#contentsprintoptions-callback) and [webContents.printToPDF()](https://www.electronjs.org/docs/latest/api/web-contents#contentsprinttopdfoptions) documentation.
163+
128164
This returns the PDF data in a `base64_encoded` binary string. So be sure to `base64_decode` it before storing it to
129165
disk:
130166

0 commit comments

Comments
 (0)