Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FAQ regarding blank rendering. #85

Merged
merged 5 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,45 @@ Comes with a built-in profiler panel to help you during your development.
This bundle was inspired by [Gotenberg PHP](https://github.com/gotenberg/gotenberg-php).
- [Steven RENAUX](https://github.com/StevenRenaux)
- [Adrien ROCHES](https://github.com/Neirda24)
- [Hubert LENOIR](https://github.com/Jean-Beru)
Neirda24 marked this conversation as resolved.
Show resolved Hide resolved
- [All Contributors](../../contributors)

## Licence

MIT License (MIT): see the [License File](LICENSE) for more details.

## FAQ

<details>
<summary>My PDF / Screenshot is blank but I have no errors !</summary>
It may be because Gotenberg is trying to access an invalid URL (when using the `->url()` or `->route()` modes).
For example if Gotenberg tries to access a page on `https://localhost:8001` but the SSL is a local provided one. Then Chromium won't be able to authorize access to the website.
To fix this you can update your Gotenberg docker service as followed :

```diff
--- a/compose.yaml
+++ b/compose.yaml
@@ -1,6 +1,9 @@
services:
gotenberg:
image: 'gotenberg/gotenberg:8'
+ command:
+ - 'gotenberg'
+ - '--chromium-ignore-certificate-errors'
```

It can also be because from Gotenberg <abbr title="Point of View">PoV</abbr> the URL of your Symfony app is not reachable.
Let's say you are using [symfony CLI](https://symfony.com/download) to run your project locally with Gotenberg running in Docker.
You need to configure the request_context like so :

```diff
--- a/config/packages/gotenberg.yaml
+++ b/config/packages/gotenberg.yaml
@@ -6,5 +6,5 @@ framework:

sensiolabs_gotenberg:
http_client: 'gotenberg.client'
+ request_context:
+ base_uri: 'http://host.docker.internal:8000' # 8000 is the port Symfony CLI is running my app on.
```
</details>
3 changes: 2 additions & 1 deletion src/Builder/Screenshot/AbstractChromiumScreenshotBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Sensiolabs\GotenbergBundle\Builder\Screenshot;

use Sensiolabs\GotenbergBundle\Client\GotenbergClientInterface;
use Sensiolabs\GotenbergBundle\Enumeration\EmulatedMediaType;
use Sensiolabs\GotenbergBundle\Enumeration\Part;
use Sensiolabs\GotenbergBundle\Enumeration\ScreenshotFormat;
use Sensiolabs\GotenbergBundle\Exception\InvalidBuilderConfiguration;
Expand Down Expand Up @@ -156,7 +157,7 @@ public function waitForExpression(string $expression): static
*
* @see https://gotenberg.dev/docs/routes#console-exceptions
*/
public function emulatedMediaType(string $mediaType): static
public function emulatedMediaType(EmulatedMediaType $mediaType): static
{
$this->formFields['emulatedMediaType'] = $mediaType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use PHPUnit\Framework\Attributes\UsesClass;
use Sensiolabs\GotenbergBundle\Builder\Screenshot\AbstractChromiumScreenshotBuilder;
use Sensiolabs\GotenbergBundle\Builder\Screenshot\AbstractScreenshotBuilder;
use Sensiolabs\GotenbergBundle\Enumeration\EmulatedMediaType;
use Sensiolabs\GotenbergBundle\Tests\Builder\AbstractBuilderTestCase;

#[CoversClass(AbstractChromiumScreenshotBuilder::class)]
Expand Down Expand Up @@ -45,7 +46,7 @@ public static function configurationIsCorrectlySetProvider(): \Generator
yield 'wait_for_expression' => ['wait_for_expression', "window.status === 'ready'", [
'waitForExpression' => "window.status === 'ready'",
]];
yield 'emulated_media_type' => ['emulated_media_type', 'screen', [
yield 'emulated_media_type' => ['emulated_media_type', EmulatedMediaType::Screen, [
'emulatedMediaType' => 'screen',
]];
yield 'cookies' => ['cookies', [['name' => 'MyCookie', 'value' => 'raspberry']], [
Expand Down