diff --git a/resources/views/docs/desktop/1/the-basics/system.md b/resources/views/docs/desktop/1/the-basics/system.md index 38674211..2717146c 100644 --- a/resources/views/docs/desktop/1/the-basics/system.md +++ b/resources/views/docs/desktop/1/the-basics/system.md @@ -111,6 +111,25 @@ System::print('...', $printer); If no `$printer` object is provided, the default printer and settings will be used. +You can also print directly to PDF: + +```php +System::printToPDF('...'); +``` + +This returns the PDF data in a `base64_encoded` binary string. So be sure to `base64_decode` it before storing it to +disk: + +```php +use Illuminate\Support\Facades\Storage; + +$pdf = System::printToPDF('...'); + +Storage::disk('desktop')->put('My Awesome File.pdf', base64_decode($pdf)); +``` + +### Print Settings + You can change the configuration before sending something to be printed, for example if you want multiple copies: ```php @@ -119,23 +138,39 @@ $printer->options['copies'] = 5; System::print('...', $printer); ``` -You can also print directly to PDF: +Additionally, both the `print()` and `printToPDF()` methods accept an optional `$settings` parameter that allows you to customize the print behavior: ```php -System::printToPDF('...'); +System::print('...', $printer, $settings); ``` -This returns the PDF data in a `base64_encoded` binary string. So be sure to `base64_decode` it before storing it to -disk: +#### Print Settings Examples + +You can customize print behavior using the settings array. Here are some common examples: ```php -use Illuminate\Support\Facades\Storage; +// Print with custom page size and orientation +$settings = [ + 'pageSize' => 'A4', + 'landscape' => true, +]; -$pdf = System::printToPDF('...'); +System::print('...', $printer, $settings); +``` -Storage::disk('desktop')->put('My Awesome File.pdf', base64_decode($pdf)); +```php +// Print multiple copies with duplex +$settings = [ + 'copies' => 3, + 'duplexMode' => 'longEdge', // 'simplex', 'shortEdge', 'longEdge' + 'color' => false, // true for color, false for monochrome +]; + +System::print('...', $printer, $settings); ``` +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. + ## Time Zones PHP and your Laravel application will generally be configured to work with a specific time zone. This could be UTC, for