playwright
playwright copied to clipboard
[Bug]: Cannot generate large PDF (Cannot create a string longer than 0x1fffffe8 characters)
Version
1.50.0-beta-2
Steps to reproduce
Exception if the resulting pdf-file is greater than 512mb
var pdfByteArray = await page.PdfAsync(new PagePdfOptions
{
Width = $"{options.WidthPx}px",
Height = $"{options.HeightPx}px",
HeaderTemplate = options.HeaderTemplateHtml,
FooterTemplate = options.FooterTemplateHtml,
DisplayHeaderFooter = options.DisplayHeaderFooter,
PrintBackground = true,
PreferCSSPageSize = true,
Margin = new Margin
{
Bottom = options.Margin?.BottomPx != null ? $"{options.Margin?.BottomPx}px" : null,
Left = options.Margin?.LeftPx != null ? $"{options.Margin?.LeftPx}px" : null,
Right = options.Margin?.RightPx != null ? $"{options.Margin?.RightPx}px" : null,
Top = options.Margin?.TopPx != null ? $"{options.Margin?.TopPx}px" : null
},
});
Expected behavior
Large PDFs (Greater than 512mb) should be generated.
Actual behavior
Exception
Cannot create a string longer than 0x1fffffe8 characters
Microsoft.Playwright.PlaywrightException: Cannot create a string longer than 0x1fffffe8 characters
at Microsoft.Playwright.Transport.Connection.InnerSendMessageToServerAsync[T](ChannelOwner object, String method, Dictionary`2 dictionary, Boolean keepNulls) in /_/src/Playwright/Transport/Connection.cs:line 206
at Microsoft.Playwright.Transport.Connection.WrapApiCallAsync[T](Func`1 action, Boolean isInternal) in /_/src/Playwright/Transport/Connection.cs:line 532
at Microsoft.Playwright.Core.Page.PdfAsync(PagePdfOptions options) in /_/src/Playwright/Core/Page.cs:line 891
Additional context
It looks like in playwright this issue is caused by base64. Maybe it can help to solve: https://github.com/microsoft/playwright/issues/14675
Environment
- Operating System: [Windows 11]
- CPU: [x64]
- Browser: [Chromium]
- .NET Version (TFM): [net8.0]
- Other info: