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.

Hang when creating PDF

See original GitHub issue

Description

Exporting as PDF hangs and never completes. I’ve tried the following combinations

  • BrowserFetcher.DefaultRevision (543305) and the current puppeteer version (571375)
  • Platform.Win32 vs Platform.Win64
  • It works if I run \Win64-571375\chrome-win32\chrome.exe --headless --disable-gpu “https://*******.com” --print-to-pdf
  • It works if I run via puppeteer, see below
const puppeteer = require('puppeteer');

require('console-stamp')(console, '[HH:MM:ss.l]');

(async () => {
    console.log('Launching Browser');

  const browser = await puppeteer.launch();
  
  console.log('Opening new page');
  const page = await browser.newPage();
  console.log('Navigating to https://*******.com');
  await page.goto('https://*******.com', {waitUntil: 'networkidle2'});
  console.log('Exporting PDF');
  await page.pdf({path: 'proposal.pdf', format: 'A4'});
  console.log('Closing browser');
  await browser.close();
  console.log('Fin');
})();

I can give you the url I am testing with but would rather do that privately if possible.

Complete minimal example reproducing the issue

    class Program
    {
        static void Main( string[] args )
        {
            MainAsync( "https://*******.com",
                "c:\\temp\\test\\output.pdf",
                10 * 60 ).GetAwaiter().GetResult();
        }

        static async Task MainAsync( string url, string fullPath, int timeoutSeconds )
        {
            const int revision = 571375; 

            // Download Chromium if we don't already have it
            Console.WriteLine( $"Downloading Chromium version {revision}" );

            var downloader = new BrowserFetcher( new BrowserFetcherOptions()
            {
                Path = "c:\\temp\\test",
                Platform = Platform.Win32
            } );
            await downloader.DownloadAsync( revision );

            // Launch it
            Console.WriteLine( $"Launching Chromium version {revision}" );
            var browser = await Puppeteer.LaunchAsync( new LaunchOptions
            {
                Headless = true, // Print to PDF only works when headless (and we want headless anyway)
                ExecutablePath = downloader.GetExecutablePath( revision )
            } );

            // Navigate to the url and print to PDF
            Console.WriteLine( $"Navigating to url {url}" );
            var page = await browser.NewPageAsync();
            await page.GoToAsync( url, timeoutSeconds > 0 ? timeoutSeconds * 1000 : 0 );

            Console.WriteLine( $"Writing PDF to file {fullPath}" );
            await page.PdfAsync( fullPath );

            Console.WriteLine( $"Closing page" );
            await page.CloseAsync();

            Console.WriteLine( $"Closing Chromium" );
            await browser.CloseAsync();

            Console.WriteLine( $"Finished writing PDF to file" );
        }
    }

Expected behavior:

Export the pdf and exit

Actual behavior:

Gets are far as ‘Writing PDF to file …’ and then never completes. I can see 6 instances of chrome.exe running in task manager

Versions

PuppeteerSharp 1.2 .NET 4.6.2 Full Framework

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
kblokcommented, Jul 13, 2018

Thanks for all the details @spib. I’ll take a look at it.

0reactions
kblokcommented, Sep 1, 2018

@viswa18 could you try v1.5?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Acrobat freezes when printing to Adobe PDF
Launch Acrobat>click Edit>Preferences>Security( Enhanced)>uncheck the box which says Enable Enhanced Security>click OK and relaunch Acrobat and then try to ...
Read more >
PDF file hangs when opening.
When opening a .pdf file in Adobe Reader, it hangs for about 2-5 minutes before letting me do anything like enlarging or going...
Read more >
Microsoft word freezes when saving as pdf or exporting it to ...
To check if this issue is caused by the corrupted Word document, you may try creating a new blank document and save it...
Read more >
Plotting to Adobe PDF from Autodesk software takes a long ...
Plotting to Adobe PDF from Autodesk software takes a long time, hangs, or freezes.
Read more >
PDF Architect Freezes after creating PDF
With the additon of PDF Architect from previous versions of PDFCreator, my computer will constantly hang for a good 2 minutes while it...
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