diff --git a/src/Modules/ChromiumPdf.php b/src/Modules/ChromiumPdf.php index 48b7acf..fed95ad 100644 --- a/src/Modules/ChromiumPdf.php +++ b/src/Modules/ChromiumPdf.php @@ -76,6 +76,16 @@ public function preferCssPageSize(): self return $this; } + /** + * Embeds the document outline into the PDF. + */ + public function generateDocumentOutline(): self + { + $this->formValue('generateDocumentOutline', true); + + return $this; + } + /** * Prints the background graphics. */ diff --git a/tests/Modules/ChromiumPdfTest.php b/tests/Modules/ChromiumPdfTest.php index 6f97aee..b542394 100644 --- a/tests/Modules/ChromiumPdfTest.php +++ b/tests/Modules/ChromiumPdfTest.php @@ -28,6 +28,7 @@ function ( float|string $marginLeft = 0, float|string $marginRight = 0, bool $preferCssPageSize = false, + bool $generateDocumentOutline = false, bool $printBackground = false, bool $omitBackground = false, bool $landscape = false, @@ -62,6 +63,7 @@ function ( $marginLeft, $marginRight, $preferCssPageSize, + $generateDocumentOutline, $printBackground, $omitBackground, $landscape, @@ -102,6 +104,7 @@ function ( $marginLeft, $marginRight, $preferCssPageSize, + $generateDocumentOutline, $printBackground, $omitBackground, $landscape, @@ -142,6 +145,7 @@ function ( true, true, true, + true, 1.0, '1-2', Stream::string('my_header.html', 'Header content'), @@ -192,6 +196,7 @@ function ( float|string $marginLeft = 0, float|string $marginRight = 0, bool $preferCssPageSize = false, + bool $generateDocumentOutline = false, bool $printBackground = false, bool $omitBackground = false, bool $landscape = false, @@ -226,6 +231,7 @@ function ( $marginLeft, $marginRight, $preferCssPageSize, + $generateDocumentOutline, $printBackground, $omitBackground, $landscape, @@ -268,6 +274,7 @@ function ( $marginLeft, $marginRight, $preferCssPageSize, + $generateDocumentOutline, $printBackground, $omitBackground, $landscape, @@ -307,6 +314,7 @@ function ( true, true, true, + true, 1.0, '1-2', Stream::string('my_header.html', 'Header content'), @@ -359,6 +367,7 @@ function ( float|string $marginLeft = 0, float|string $marginRight = 0, bool $preferCssPageSize = false, + bool $generateDocumentOutline = false, bool $printBackground = false, bool $omitBackground = false, bool $landscape = false, @@ -393,6 +402,7 @@ function ( $marginLeft, $marginRight, $preferCssPageSize, + $generateDocumentOutline, $printBackground, $omitBackground, $landscape, @@ -440,6 +450,7 @@ function ( $marginLeft, $marginRight, $preferCssPageSize, + $generateDocumentOutline, $printBackground, $omitBackground, $landscape, @@ -488,6 +499,7 @@ function ( true, true, true, + true, 1.0, '1-2', Stream::string('my_header.html', 'Header content'), @@ -536,6 +548,7 @@ function hydrateChromiumPdfFormData( float|string $marginLeft = 0, float|string $marginRight = 0, bool $preferCssPageSize = false, + bool $generateDocumentOutline = false, bool $printBackground = false, bool $omitBackground = false, bool $landscape = false, @@ -575,6 +588,10 @@ function hydrateChromiumPdfFormData( $chromium->preferCssPageSize(); } + if ($generateDocumentOutline) { + $chromium->generateDocumentOutline(); + } + if ($printBackground) { $chromium->printBackground(); } @@ -688,6 +705,7 @@ function expectChromiumPdfOptions( float|string $marginLeft, float|string $marginRight, bool $preferCssPageSize, + bool $generateDocumentOutline, bool $printBackground, bool $omitBackground, bool $landscape, @@ -728,6 +746,7 @@ function expectChromiumPdfOptions( } expect($body)->unless($preferCssPageSize === false, fn ($body) => $body->toContainFormValue('preferCssPageSize', '1')); + expect($body)->unless($generateDocumentOutline === false, fn ($body) => $body->toContainFormValue('generateDocumentOutline', '1')); expect($body)->unless($printBackground === false, fn ($body) => $body->toContainFormValue('printBackground', '1')); expect($body)->unless($omitBackground === false, fn ($body) => $body->toContainFormValue('omitBackground', '1')); expect($body)->unless($landscape === false, fn ($body) => $body->toContainFormValue('landscape', '1'));