Skip to content
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ class YourController
7. [Convert Builder](./docs/pdf/ConvertPdfBuilder.md)
8. [Split Builder](./docs/pdf/SplitPdfBuilder.md)
9. [Flatten Builder](./docs/pdf/FlattenPdfBuilder.md)
10. [Encrypt Builder](./docs/pdf/EncryptPdfBuilder.md)

### Screenshot

Expand Down
9 changes: 9 additions & 0 deletions config/builder_pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use Sensiolabs\GotenbergBundle\Builder\Pdf\ConvertPdfBuilder;
use Sensiolabs\GotenbergBundle\Builder\Pdf\EmbedPdfBuilder;
use Sensiolabs\GotenbergBundle\Builder\Pdf\EncryptPdfBuilder;
use Sensiolabs\GotenbergBundle\Builder\Pdf\FlattenPdfBuilder;
use Sensiolabs\GotenbergBundle\Builder\Pdf\HtmlPdfBuilder;
use Sensiolabs\GotenbergBundle\Builder\Pdf\LibreOfficePdfBuilder;
Expand Down Expand Up @@ -83,6 +84,14 @@
->configurator(service('sensiolabs_gotenberg.builder_configurator'))
;

// Encrypt
$services->set('.sensiolabs_gotenberg.pdf_builder.encrypt', EncryptPdfBuilder::class)
->share(false)
->parent('.sensiolabs_gotenberg.abstract_builder')
->tag('sensiolabs_gotenberg.builder')
->configurator(service('sensiolabs_gotenberg.builder_configurator'))
;

// Embed
$services->set('.sensiolabs_gotenberg.pdf_builder.embed', EmbedPdfBuilder::class)
->share(false)
Expand Down
4 changes: 3 additions & 1 deletion docs/generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Sensiolabs\GotenbergBundle\Builder\BuilderInterface;
use Sensiolabs\GotenbergBundle\Builder\Pdf\ConvertPdfBuilder;
use Sensiolabs\GotenbergBundle\Builder\Pdf\EmbedPdfBuilder;
use Sensiolabs\GotenbergBundle\Builder\Pdf\EncryptPdfBuilder;
use Sensiolabs\GotenbergBundle\Builder\Pdf\FlattenPdfBuilder;
use Sensiolabs\GotenbergBundle\Builder\Pdf\HtmlPdfBuilder;
use Sensiolabs\GotenbergBundle\Builder\Pdf\LibreOfficePdfBuilder;
Expand Down Expand Up @@ -60,14 +61,15 @@ class BuilderParser
public const BUILDERS = [
'pdf' => [
ConvertPdfBuilder::class,
EncryptPdfBuilder::class,
EmbedPdfBuilder::class,
FlattenPdfBuilder::class,
HtmlPdfBuilder::class,
LibreOfficePdfBuilder::class,
MarkdownPdfBuilder::class,
MergePdfBuilder::class,
SplitPdfBuilder::class,
UrlPdfBuilder::class,
EmbedPdfBuilder::class,
],
'screenshot' => [
HtmlScreenshotBuilder::class,
Expand Down
175 changes: 175 additions & 0 deletions docs/pdf/EncryptPdfBuilder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
## EncryptPdfBuilder
> [!TIP]
> See: [https://gotenberg.dev/docs/routes#encrypt-route](https://gotenberg.dev/docs/routes#encrypt-route)

## Basic usage

> [!WARNING]
> As assets files, by default the PDF files are fetch in the assets folder of
> your application.
> For more information about path resolution go to [assets documentation](../assets.md).
> [!WARNING]
> You must provide at least the User Password
```php
namespace App\Controller;

use Sensiolabs\GotenbergBundle\GotenbergPdfInterface;

class YourController
{
public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response
{
return $gotenberg->encrypt()
->files('document_1.pdf')
->userPassword('MyUserPassword')
->ownerPassword('MyOwnerPassword')
->generate()
;
}
}
```
<!-- AUTO generated doc from generate.php -->
<!-- AUTO-GENERATED:START -->
## Customization

### Available methods

- [downloadFrom](#downloadfromarray-downloadfrom)
- [files](#filesstringablestring-paths)
- [webhook](#webhookarray-webhook)
- [webhookConfiguration](#webhookconfigurationstring-name)
- [webhookErrorRoute](#webhookerrorroutestring-route-array-parameters-string-method)
- [webhookErrorUrl](#webhookerrorurlstring-url-string-method)
- [webhookExtraHeaders](#webhookextraheadersarray-extrahttpheaders)
- [webhookRoute](#webhookroutestring-route-array-parameters-string-method)
- [webhookUrl](#webhookurlstring-url-string-method)
- [ownerPassword](#ownerpasswordstring-ownerpassword)
- [userPassword](#userpasswordstring-userpassword)

### downloadFrom(array \$downloadFrom)
Sets download from to download each entry (file) in parallel (URLs MUST return a Content-Disposition header with a filename parameter.).<br />

> [!TIP]
> See: [https://gotenberg.dev/docs/routes#download-from](https://gotenberg.dev/docs/routes#download-from)

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->downloadFrom([['url' => 'http://example.com/url/to/file', 'extraHttpHeaders' => ['MyHeader' => 'MyValue']], ['url' => 'http://example.com/url/to/file', 'extraHttpHeaders' => ['MyHeaderOne' => 'MyValue', 'MyHeaderTwo' => 'MyValue']]])
->generate()
->stream()
;
```

### files(Stringable|string ...\$paths)

### webhook(array \$webhook)
> [!TIP]
> See: [https://gotenberg.dev/docs/webhook](https://gotenberg.dev/docs/webhook)

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->webhook(['config_name' => 'my_config', 'success' => ['url' => 'https://my.webhook.url/success', 'method' => 'POST'], 'error' => ['route' => 'my_route_error', 'method' => 'POST']])
->generate()
->stream()
;
```

### webhookConfiguration(string \$name)
Providing an existing $name from the configuration file, it will correctly set both success and error webhook URLs as well as extra_http_headers if defined.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->webhookConfiguration('my_webhook_config')
->generate()
->stream()
;
```

### webhookErrorRoute(string \$route, array \$parameters, ?string \$method)
Sets the webhook route with params and method for cases of error.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->webhookErrorRoute('my_route_error', ['foo' => 'bar'], 'PUT')
->generate()
->stream()
;
```

### webhookErrorUrl(string \$url, ?string \$method)
Sets the webhook for cases of success.<br />Optionally sets a custom HTTP method for such endpoint among : POST, PUT or PATCH.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->webhookErrorUrl('https://my.webhook.url', 'PUT')
->generate()
->stream()
;
```

### webhookExtraHeaders(array \$extraHttpHeaders)
Extra headers that will be provided to the webhook endpoint. May it either be Success or Error.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->webhookExtraHeaders(['Authorization' => 'Bearer my-secret-token','X-Custom-Header' => 'CustomValue'])
->generate()
->stream()
;
```

### webhookRoute(string \$route, array \$parameters, ?string \$method)
Sets the webhook route with params and method for cases of success.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->webhookRoute('my_route_success', ['foo' => 'bar'], 'PUT')
->generate()
->stream()
;
```

### webhookUrl(string \$url, ?string \$method)
Sets the webhook for cases of success.<br />Optionally sets a custom HTTP method for such endpoint among : POST, PUT or PATCH.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->webhookUrl('https://my.webhook.url', 'PUT')
->generate()
->stream()
;
```


### ownerPassword(?string \$ownerPassword)
Set PDF owner password.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->ownerPassword('OwnerDefinedPassword')
->generate()
->stream()
;
```

### userPassword(?string \$userPassword)
Set PDF user password.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->userPassword('UserDefinedPassword')
->generate()
->stream()
;
```

27 changes: 27 additions & 0 deletions docs/pdf/HtmlPdfBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ class YourController
- [footerFile](#footerfilestring-path)
- [header](#headerstring-template-array-context)
- [headerFile](#headerfilestring-path)
- [ownerPassword](#ownerpasswordstring-ownerpassword)
- [userPassword](#userpasswordstring-userpassword)
- [failOnConsoleExceptions](#failonconsoleexceptionsbool-bool)
- [failOnHttpStatusCodes](#failonhttpstatuscodesarray-statuscodes)
- [failOnResourceHttpStatusCodes](#failonresourcehttpstatuscodesarray-statuscodes)
Expand Down Expand Up @@ -792,6 +794,31 @@ return $gotenberg
```


### ownerPassword(?string \$ownerPassword)
Set PDF owner password.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->ownerPassword('OwnerDefinedPassword')
->generate()
->stream()
;
```

### userPassword(?string \$userPassword)
Set PDF user password.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->userPassword('UserDefinedPassword')
->generate()
->stream()
;
```


### failOnConsoleExceptions(bool \$bool)
Forces GotenbergPdf to return a 409 Conflict response if there are<br />exceptions in the Chromium console. (default false).<br />

Expand Down
27 changes: 27 additions & 0 deletions docs/pdf/LibreOfficePdfBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ class YourController
- [webhookExtraHeaders](#webhookextraheadersarray-extrahttpheaders)
- [webhookRoute](#webhookroutestring-route-array-parameters-string-method)
- [webhookUrl](#webhookurlstring-url-string-method)
- [ownerPassword](#ownerpasswordstring-ownerpassword)
- [userPassword](#userpasswordstring-userpassword)

### addMetadata(string \$key, string \$value)
If you want to add metadata from the ones already loaded in the configuration.<br />
Expand Down Expand Up @@ -673,3 +675,28 @@ return $gotenberg
;
```


### ownerPassword(?string \$ownerPassword)
Set PDF owner password.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->ownerPassword('OwnerDefinedPassword')
->generate()
->stream()
;
```

### userPassword(?string \$userPassword)
Set PDF user password.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->userPassword('UserDefinedPassword')
->generate()
->stream()
;
```

27 changes: 27 additions & 0 deletions docs/pdf/MarkdownPdfBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ class YourController
- [footerFile](#footerfilestring-path)
- [header](#headerstring-template-array-context)
- [headerFile](#headerfilestring-path)
- [ownerPassword](#ownerpasswordstring-ownerpassword)
- [userPassword](#userpasswordstring-userpassword)
- [failOnConsoleExceptions](#failonconsoleexceptionsbool-bool)
- [failOnHttpStatusCodes](#failonhttpstatuscodesarray-statuscodes)
- [failOnResourceHttpStatusCodes](#failonresourcehttpstatuscodesarray-statuscodes)
Expand Down Expand Up @@ -843,6 +845,31 @@ return $gotenberg
```


### ownerPassword(?string \$ownerPassword)
Set PDF owner password.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->ownerPassword('OwnerDefinedPassword')
->generate()
->stream()
;
```

### userPassword(?string \$userPassword)
Set PDF user password.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->userPassword('UserDefinedPassword')
->generate()
->stream()
;
```


### failOnConsoleExceptions(bool \$bool)
Forces GotenbergPdf to return a 409 Conflict response if there are<br />exceptions in the Chromium console. (default false).<br />

Expand Down
27 changes: 27 additions & 0 deletions docs/pdf/MergePdfBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class YourController
- [webhookExtraHeaders](#webhookextraheadersarray-extrahttpheaders)
- [webhookRoute](#webhookroutestring-route-array-parameters-string-method)
- [webhookUrl](#webhookurlstring-url-string-method)
- [ownerPassword](#ownerpasswordstring-ownerpassword)
- [userPassword](#userpasswordstring-userpassword)

### addMetadata(string \$key, string \$value)
If you want to add metadata from the ones already loaded in the configuration.<br />
Expand Down Expand Up @@ -261,3 +263,28 @@ return $gotenberg
;
```


### ownerPassword(?string \$ownerPassword)
Set PDF owner password.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->ownerPassword('OwnerDefinedPassword')
->generate()
->stream()
;
```

### userPassword(?string \$userPassword)
Set PDF user password.<br />

```php
return $gotenberg
// Your builder call as ->html() and the rest of your configuration code
->userPassword('UserDefinedPassword')
->generate()
->stream()
;
```

Loading