question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not all links produce an export

See original GitHub issue

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:

  • An unhandled exception of type ‘System.NotImplementedException’ occurred in mscorlib.dll The method or operation is not implemented.
  • I have noticed for each link a new chromium instance gets opened but never closed is there a way to do this with this code?
foreach (var list_item in sql_list)
{
    string id = list_item.Item2.ToString();
    string extension = ".pdf";
    string exportname = id + extension;
    var chromiumRevision = 526987;

    Console.WriteLine("Downloading chromium");
    await Downloader.CreateDefault().DownloadRevisionAsync(chromiumRevision);

    Console.WriteLine("Navigating " + list_item.Item1);
    var browser = await Puppeteer.LaunchAsync(new LaunchOptions
    {
        Headless = true
    }, chromiumRevision);

    var page = await browser.NewPageAsync();
    await page.GoToAsync(list_item.Item1);

    Console.WriteLine("Generating PNG");
    await page.PdfAsync(Path.Combine(directory,exportname));

    Console.WriteLine("Export " + exportname + " completed");
    Console.WriteLine();

}

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kblokcommented, Mar 20, 2018

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.

1reaction
Meir017commented, Mar 20, 2018

You should move the creation of the Browser into a using statement

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hyperlinks don't Export/Save-as when making PDF's on a ...
Text hyperlinks export correctly to PDF. Hyperlinks on shapes do not. Please convert your shape hyperlinks to text hyperlinks, then try again.
Read more >
InDesign export error message
I am trying to export an InDesign file to PDF and am receiving two error messages. First - "This document contains links to...
Read more >
PDF Export not attaching all links
Creating a one pager and need links to be exported with the PDF. For some reason only a few of the links are...
Read more >
Hyperlinks not Clickable when Exported to excel
When I run a query, the results of it are exported to the Excel. This data has few hyperlinks which get displayed in...
Read more >
Links Not Working/Not Clickable in Exported PDFs? FIXED!
Links Not Working/Not Clickable in Exported PDFs? FIXED! If you, like me, use Pages to create doc s and then export them to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found