Closed Speta643 closed 6 years ago
You should move the creation of the Browser into a using statement
Your code should look something like this:
Console.WriteLine("Downloading chromium"); await Downloader.CreateDefault().DownloadRevisionAsync(Downloader.DefaultRevision);
var sql_list = new Tuple<string,string>[]
{
new Tuple<string, string>("site2", "https://www.wunderground.com/weather/be/antwerp"),
new Tuple<string, string>("site1", "https://darksky.net/forecast/51.2211,4.3997/si12/en")
};
var options = new LaunchOptions
{
Headless = true
};
using (var browser = await Puppeteer.LaunchAsync(options, Downloader.DefaultRevision))
{
foreach (var list_item in sql_list)
{
string id = list_item.Item1;
string extension = ".pdf";
string exportname = id + extension;
Console.WriteLine("Navigating " + list_item.Item2);
using (var page = await browser.NewPageAsync())
{
await page.GoToAsync(list_item.Item2);
Console.WriteLine("Generating PNG");
await page.PdfAsync(Path.Combine(Directory.GetCurrentDirectory(), exportname));
Console.WriteLine("Export " + exportname + " completed");
Console.WriteLine();
}
}
}
I took the URLs from the comment you made in one comment. We're failing at creating PDFs for both. So it's something we need to take a look at.
Hey again, do you have an estimation of when this bug will be resolved? also it works with NodeJS and the cli
@Speta643 I'll make a release this week with this fix.
@Speta643 I've just published v0.3.2, Could you take a look?
As stated yesterday not all links produce an export when this happens i get put into break mode and gives me an error that states the following: