mvlabs / MvlabsSnappy

MvlabsSnappy is a ZF2/ZF3 module that allow easy to thumbnail, snapshot or PDF generation from a url or a html page using Snappy PHP (5.6+) wrapper for the wkhtmltopdf/wkhtmltoimage conversion utility.
MIT License
24 stars 10 forks source link

ContentOperationNotPermittedError #11

Open barry1955 opened 6 years ago

barry1955 commented 6 years ago

We have been using the mvlabs snappy for a few years now. Recently we were testing a new release and we ran into an issue whereby the mvlabs pdf service is not working as before.

I get this above error now but as far as the team is aware we have made no changes to any code that touches the module.

See error listing below

`An error occurred An error occurred during execution; please try again later. Additional information: RuntimeException File: C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\knplabs\knp-snappy\src\Knp\Snappy\AbstractGenerator.php:333 Message: The exit status code '1' says something went wrong: stderr: "Loading pages (1/6) [> ] 0% [======> ] 10% [=========> ] 15% [=========> ] 15% [==========> ] 17% [============> ] 21% [=============> ] 23% [===============> ] 26% [================> ] 28% [==================> ] 30% [===================> ] 33% [======================> ] 37% [========================> ] 41% [==========================> ] 44% [============================> ] 47% [============================> ] 48% [==============================> ] 50% [================================> ] 54% [====================================> ] 60% [========================================> ] 67% [==========================================> ] 71% [==============================================> ] 78% [================================================> ] 80% [===================================================> ] 85% [====================================================> ] 87% Warning: SSL error ignored
Warning: SSL error ignored Warning: SSL error ignored Warning: SSL error ignored Warning: SSL error ignored Warning: SSL error ignored [====================================================> ] 87% [====================================================> ] 87% [====================================================> ] 87% [====================================================> ] 87% [====================================================> ] 88% [====================================================> ] 88% [====================================================> ] 88% [====================================================> ] 88% [====================================================> ] 88% [====================================================> ] 88% [============================================================] 100% Counting pages (2/6)
[============================================================] Object 1 of 1 Resolving links (4/6)
[============================================================] Object 1 of 1 Loading headers and footers (5/6)
Printing pages (6/6) [> ] Preparing [============================================================] Page 1 of 1 Done
Exit with code 1 due to network error: ContentOperationNotPermittedError " stdout: "" command: /usr/local/bin/wkhtmltopdf.exe --lowquality --margin-bottom "0" --margin-left "6" --margin-right "0" --margin-top "4" --orientation "Landscape" --page-size "A4" --javascript-delay "6000" --zoom "1.2" "C:\WINDOWS\TEMP\knp_snappy5b7b5844bbdec8.14741832.html" "C:\WINDOWS\TEMP\knp_snappy5b7b5844bc0a05.11040490.pdf". Stack trace:

0 C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\knplabs\knp-snappy\src\Knp\Snappy\AbstractGenerator.php(148): Knp\Snappy\AbstractGenerator->checkProcessStatus(1, '', 'Loading pages (...', '/usr/local/bin/...')

1 C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\knplabs\knp-snappy\src\Knp\Snappy\Pdf.php(57): Knp\Snappy\AbstractGenerator->generate(Array, 'C:\WINDOWS\TEMP...', Array, false)

2 C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\knplabs\knp-snappy\src\Knp\Snappy\AbstractGenerator.php(177): Knp\Snappy\Pdf->generate(Array, 'C:\WINDOWS\TEMP...', Array)

3 C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\knplabs\knp-snappy\src\Knp\Snappy\AbstractGenerator.php(198): Knp\Snappy\AbstractGenerator->getOutput(Array, Array)

4 C:\usr\share\AssetWhere\Release 4.5\assetwhere\module\Application\src\Application\Controller\PrintController.php(204): Knp\Snappy\AbstractGenerator->getOutputFromHtml('...', Array)

5 C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\zendframework\zend-mvc\src\Controller\AbstractActionController.php(82): Application\Controller\PrintController->printAction()

6 [internal function]: Zend\Mvc\Controller\AbstractActionController->onDispatch(Object(Zend\Mvc\MvcEvent))

7 C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\zendframework\zend-eventmanager\src\EventManager.php(490): call_user_func(Array, Object(Zend\Mvc\MvcEvent))

8 C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\zendframework\zend-eventmanager\src\EventManager.php(214): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

9 C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\zendframework\zend-mvc\src\Controller\AbstractController.php(118): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

10 C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\zendframework\zend-mvc\src\DispatchListener.php(93): Zend\Mvc\Controller\AbstractController->dispatch(Object(ZF\ContentNegotiation\Request), Object(Zend\Http\PhpEnvironment\Response))

11 [internal function]: Zend\Mvc\DispatchListener->onDispatch(Object(Zend\Mvc\MvcEvent))

12 C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\zendframework\zend-eventmanager\src\EventManager.php(490): call_user_func(Array, Object(Zend\Mvc\MvcEvent))

13 C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\zendframework\zend-eventmanager\src\EventManager.php(214): Zend\EventManager\EventManager->triggerListeners('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

14 C:\usr\share\AssetWhere\Release 4.5\assetwhere\vendor\zendframework\zend-mvc\src\Application.php(314): Zend\EventManager\EventManager->trigger('dispatch', Object(Zend\Mvc\MvcEvent), Object(Closure))

15 C:\usr\share\AssetWhere\Release 4.5\assetwhere\public\index.php(31): Zend\Mvc\Application->run()

16 {main}`

I note that is is including file from c:\windows\temp - which is outside the document root. would this cause the issue on an SSL site?

drigani commented 6 years ago

Hi @barry1955, I think that could be a problem related to one asset in the html (css, js, images). Below you'll find the final command using wkhtmltopdf executed from Snappy, in way to test it from command line:

/usr/local/bin/wkhtmltopdf.exe --lowquality --margin-bottom "0" --margin-left "6" --margin-right "0" --margin-top "4" --orientation "Landscape" --page-size "A4" --javascript-delay "6000" --zoom "1.2" "C:\WINDOWS\TEMP\knp_snappy5b7b5844bbdec8.14741832.html

barry1955 commented 6 years ago

Thank you very much for the feedback, I've been on the road for 2 weeks, hopefully I'll get this resolved soon.

We use the htmltoPdf tool to allow printing out of maps, and the existing code has been working in-situ for a while now, the main difference has been the inclusion of SSL.

Again, thank you for the response, I'll be looking into this today.