-
Notifications
You must be signed in to change notification settings - Fork 164
Open
Labels
questionFurther information is requestedFurther information is requested
Description
I've got a page, it contains a line chart. Everything is fine with the page when viewing it in my browser. But when I use Playwright to print the page, the chart never appears.
I guess it's down to the fact that the chart is drawn in a Canvas.
I observed that, when viewing normally, SetupCompletedCallback is called, but it is never called when the page is loaded by Playwright.
Here's my Playwright code:
using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = true });
var page = await browser.NewPageAsync();
string url = _getCurrentServerAddress.Get();
IResponse? response = await page.GotoAsync(
$"{url}/PrintReport",
new PageGotoOptions
{
WaitUntil = WaitUntilState.NetworkIdle
});
await page.WaitForLoadStateAsync(LoadState.NetworkIdle);
// Generate the PDF
var margin = "16px";
string content = await page.ContentAsync();
byte[] output = await page.PdfAsync(new PagePdfOptions
{
Format = "A4", // or "letter"
Landscape = false,
Path = "output.pdf",
Margin = new Margin { Top = margin, Left = margin, Bottom = margin, Right = margin },
PrintBackground = true,
DisplayHeaderFooter = false
});
await page.CloseAsync();Any ideas? I guess it's a combination of js and canvas, but I've exhausted what I've found online on how to fix it.
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested