• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rich-id / pdf-template-bundle / #27

12 Jul 2024 10:51AM UTC coverage: 0.0%. Remained the same
#27

push

Dumazeau
Increase Timeout

0 of 1 new or added line in 1 file covered. (0.0%)

0 of 179 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Domain/Pdf/Trait/PdfGeneratorTrait.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace RichId\PdfTemplateBundle\Domain\Pdf\Trait;
6

7
use HeadlessChromium\BrowserFactory;
8
use HeadlessChromium\Page;
9
use RichId\PdfTemplateBundle\Domain\Port\ConfigurationInterface;
10
use Symfony\Contracts\Service\Attribute\Required;
11

12
trait PdfGeneratorTrait
13
{
14
    #[Required]
15
    public ConfigurationInterface $configuration;
16

17
    /** @return array<string, mixed> */
18
    abstract protected function getPdfOptions(): array;
19
    abstract protected function updatePage(Page $page): void;
20

21
    private function internalGeneratePdf(string $content, int $timeout = 10000): string
22
    {
23
        $browserFactory = new BrowserFactory($this->configuration->getChromeBinary());
×
24
        $browser = $browserFactory->createBrowser(['customFlags' => $this->configuration->getChromeCustomFlags()]);
×
25

26
        try {
27
            $page = $browser->createPage();
×
28
            $page->setHtml($content, $timeout);
×
29
            $this->updatePage($page);
×
NEW
30
            $pdf = \base64_decode($page->pdf($this->getPdfOptions())->getBase64($timeout));
×
31

32
            $browser->close();
×
33

34
            return $pdf;
×
35
        } finally {
36
            $browser->close();
×
37
        }
38
    }
39
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc