When I try to save the file locally, the response object is returned null .The page I'm trying to capture takes a lot of loading time for which I need a callback to notify me when all page resources are completely loaded. Is my approach correct ?
When not trying to save the file locally the response object returned is not null.
Here's my code:
$client = Client::getInstance();
$client->getEngine()->setPath('path/to/phantomjs');
$client->isLazy();
$request = $client->getMessageFactory()->createPdfRequest('http://google.com');
$response = $client->getMessageFactory()->createResponse();
$file = 'path/binfile.pdf';
$request->setOutputFile($file);
$client->send($request, $response);
How do I achieve and know when all the page resources are completely loaded ?
The solution for me was to install phantomjs from my package manager (sudo apt-get install phantomjs) and refer the engine to it, rather than to the phantomjs binary downloaded by composer.
$this->client->getEngine()->setPath('/usr/bin/phantomjs');
For more info refer this thread : https://github.com/jonnnnyw/php-phantomjs/issues/86
or even this thread: https://github.com/jonnnnyw/php-phantomjs/issues/57
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With