Skip to content

Commit 07a3b69

Browse files
authored
PDF troubleshooting (#2755)
* PDF troubleshooting * Update docfx_project/docs/IssuesGeneratingPdfFiles.md
1 parent a4f43fa commit 07a3b69

17 files changed

+48
-18
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,8 @@ Thumbs.db
294294

295295
demos/PuppeteerSharpPdfDemo/google.pdf
296296
demos/PuppeteerSharpPdfDemo/.local-chromium/
297-
docs/
297+
/docs
298298
samples/PupppeterSharpAspNetFrameworkSample/PupppeterSharpAspNetFrameworkSample/App_Data/
299-
300299
# Visual Studio Code user config directory
301300
.vscode/
302301
tools/github-ops/.env
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Issues generating PDF files
2+
_Contributors: [Dario Kondratiuk](https://github.com/kblok)_
3+
4+
## Symptoms
5+
6+
When generating PDF files using `PdfAsync`, everything works fine in your development environment. However, once you deploy your application to a server, you get a timeout.
7+
8+
## Problem
9+
10+
Since Chromium version 125, generating PDF files requires sandbox permissions. [See chromium issue](https://issues.chromium.org/issues/338553158).
11+
PuppeteerSharp tries to apply these permissions after the browser is downloaded, but it will proceed if this step fails. We want to ensure your application does not break if it never reaches the point of generating a PDF file.
12+
13+
## Solution
14+
15+
Verify whether PuppeteerSharp successfully applied the sandbox permissions. This can be done by checking the `InstalledBrowser.PermissionsFixed` property.
16+
17+
```csharp
18+
var browserFetcher = new BrowserFetcher();
19+
var installedBrowser = await browserFetcher.DownloadAsync(BrowserFetcher.);
20+
21+
if (!installedBrowser.PermissionsFixed)
22+
{
23+
Console.WriteLine("Sandbox permissions were not applied. You need to run your application as an administrator.");
24+
return;
25+
}
26+
```
27+
28+
If PuppeteerSharp did not manage to apply the sandbox permissions, you can manually fix this by running the `setup.exe` file that was downloaded with the browser:
29+
30+
```bash
31+
cd <path-to-browser>
32+
.\setup.exe --configure-browser-in-directory="<path-to-browser>"
33+
```
34+
35+
If that doesn't work. You can try by fixing the permissions manually. You can find the instructions [here](https://pptr.dev/troubleshooting#chrome-reports-sandbox-errors-on-windows).
36+
37+
## Recommended approach
38+
39+
Installing the browser during runtime is not recommended, as it takes time and can delay your application. It is advisable to install the browser beforehand and pass the path to the `LaunchAsync` method.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)