The exit status code '1' says something went wrong [knp snappy]
This mean's that one of the resources in your HTML file can't be loaded by wkhtmltopdf, check in your HTML file if all your resources have an absolute URL like this : http://www.yourserver.com/images/myimage.jpg
If it's not the case try to set it :
{{ app.request.schemeAndHttpHost ~ 'resource relative url' }}
If you are loading assets with assetic in {% stylesheets %}
or {% javascript %}
or {% image %}
you can also do
{{ app.request.schemeAndHttpHost ~ asset_url }}
![Rodrigo Díaz R.](https://i.stack.imgur.com/OXx2R.jpg?s=256&g=1)
Rodrigo Díaz R.
Updated on June 08, 2022Comments
-
Rodrigo Díaz R. about 2 years
I'm working with knp snappy bundle for generate reports from my app. But doesn't work, when I call my controller for generate the pdf throws the next error:
The exit status code '1' says something went wrong: stderr: "Loading pages (1/6) [> ] 0% [======> ] 10% [=======> ] 12% Warning: Failed to load file:///gestionresiduospel/web/bundles/usuario/css/bootstrap.css (ignore) Warning: Failed to load file:///gestionresiduospel/web/bundles/usuario/js/bootstrap.js (ignore) [============================================================] 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: ContentNotFoundError " stdout: "" command: "C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe" --lowquality "C:\Users\rodrigo\AppData\Local\Temp\knp_snappy5682878973ade7.09664058.html" "C:\Users\rodrigo\AppData\Local\Temp\knp_snappy56828789746968.46649162.pdf".
My controller is this:
public function historicosDetallePdfAction($id) { $em = $this->getDoctrine()->getManager(); //gets residuos peligrosos. $solicitudRetiro= $em->getRepository('SolicitudRetiroBundle:SolicitudRetiro')->find($id); //gets residuos no peligrosos $residuosPRetirados = $em->getRepository('SolicitudRetiroBundle:RetiroResiduo')->findResiduos($id); //retorna los residuos no peligrosos en la solicitud $residuosNPRetirados = $em->getRepository('SolicitudRetiroBundle:RetiroResiduoNoPeligroso')->findResiduosNoPeligrosos($id); // view generator $html = $this->renderView('SolicitudRetiroBundle:Pdf:resumenSolicitudResiduoRetirado.html.twig', array( 'solicitudRetiro' => $solicitudRetiro, 'residuosRetirados' => $residuosPRetirados, 'residuosNoPel' => $residuosNPRetirados )); // pdf generator return new Response( $this->get('knp_snappy.pdf')->getOutputFromHtml($html), 200, array( 'Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="historico.pdf"' ) ); }
I copied my url and run into console[CMD] with wkhtmltopdf.exe. In console my pdf is created but when I see the file only shows my login screen. So I think could be a issue about permission into my controller but I don't know how I pass this.
In other hand, if you know about another pdf generator(from html) that working into symfony this could be help me too.
I'm working under symfony2.7
-
RoboBear over 8 yearsI had this same issue and error message with wkhtmltopdfin laravel 5, and this was the problem. I had CDN assets that threw the errors. Once I used local versions instead, the PDF generation ran as expected.
-
Jean-Charles LUC almost 5 yearsHi, where should i put {{ app.request.schemeAndHttpHost ~ 'resource relative url' }} ? in html html content ? o_o