Skip to content

Commit

Permalink
Add larger timeout for PDF saveToFile to allow large PDF creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sander De la Marche committed Dec 1, 2021
1 parent 27f7406 commit 61e1061
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/Service/PdfGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Dreadnip\ChromePdfBundle\Service;

use HeadlessChromium\BrowserFactory;
use HeadlessChromium\Page;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpFoundation\RequestStack;

Expand Down Expand Up @@ -52,15 +51,10 @@ public function generate(string $html, string $path, array $printOptions = [], a
try {
$page = $browser->createPage();

/*
* We check for "network idle" instead of "load" by default to avoid
* missing resources like images and webfonts that can take a split second longer to load
*/
$page->navigate($tempUrl)->waitForNavigation(Page::NETWORK_IDLE);
$page->navigate($tempUrl)->waitForNavigation();

$page->pdf($printOptions)->saveToFile($path);
$page->pdf($printOptions)->saveToFile($path, 30000);

// Clean up the temp file
$this->fileSystem->remove($this->projectDir . 'tmp');

return $path;
Expand Down

0 comments on commit 61e1061

Please sign in to comment.