@@ -17,14 +17,15 @@ class WebdriverBackend implements PfdPrintBackend
1717{
1818 protected RemoteWebDriver $ driver ;
1919
20+
2021 public function __construct (
21- string $ url ,
22+ string $ url ,
2223 DesiredCapabilities $ capabilities ,
2324 ) {
2425 $ this ->driver = RemoteWebDriver::create ($ url , $ capabilities );
2526 }
2627
27- protected function __destruct ()
28+ public function __destruct ()
2829 {
2930 $ this ->close ();
3031 }
@@ -35,6 +36,8 @@ protected function setContent(PrintableHtmlDocument $document): void
3536 $ encoded = base64_encode ($ document );
3637 $ this ->driver ->executeScript ('document.head.remove(); ' );
3738 $ this ->driver ->executeScript ("document.body.outerHTML = atob(' $ encoded'); " );
39+ $ this ->driver ->executeScript (self ::ACTIVATE_SCRIPTS );
40+ $ this ->driver ->executeScript ('new Layout().apply(); ' );
3841 }
3942
4043 protected function waitForPageLoad (): void
@@ -71,6 +74,11 @@ public function toPdf(PrintableHtmlDocument $document): string
7174 {
7275 $ this ->setContent ($ document );
7376 $ this ->waitForPageLoad ();
77+
78+ $ path = '/tmp/chromedriver- ' . time () . '.html ' ;
79+ file_put_contents ($ path , $ this ->driver ->getPageSource ());
80+ Logger::info ("Printing page $ path. " );
81+
7482 $ printParameters = $ this ->getPrintParameters ($ document );
7583
7684 return $ this ->printToPdf ($ printParameters );
0 commit comments