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

[Bug]: Cannot generate large PDF (Cannot create a string longer than 0x1fffffe8 characters) #34593

Open
buecherlstefan opened this issue Feb 3, 2025 · 0 comments

Comments

@buecherlstefan
Copy link

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: #14675

Environment

- Operating System: [Windows 11]
- CPU: [x64]
- Browser: [Chromium]
- .NET Version (TFM): [net8.0]
- Other info:
@mxschmitt mxschmitt transferred this issue from microsoft/playwright-dotnet Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants