Nreco pdf generator: Exit with code 1 due to network error: RemoteHostClosedError

Nagesh Bhardwaj picture Nagesh Bhardwaj · Jan 17, 2017 · Viewed 7.1k times · Source

Am using nreco.pdfgenerator to convert html into pdf format. Currently am facing an issue where pdf generator tool is throwing an exception while generating the pdf when hosted in other environments. The error as follows:

NReco.PdfGenerator.WkHtmlToPdfException: Exit with code 1 due to network error: RemoteHostClosedError (exit code: 1)

I have given all the required permissions to the folders and files. Not sure about this network error. Can someone look into it ?
Thanks

Answer

Vitaliy Fedorchenko picture Vitaliy Fedorchenko · Jan 17, 2017

NReco PdfGenerator is a .NET wrapper for wkhtmltopdf tool, and this exception means that wkhtmltopdf process exited with error code, and last error message (from console log) was "Exit with code 1 due to network error: RemoteHostClosedError".

This error means that HTML document has references to external resources (images, css, js etc) and for some reason they cannot be accessed by wkhtmltopdf. Ensure that URLs are correct (if you provide HTML as C# string, all URLs should be absolute), and server where wkhtmltopdf is executed can download these URLs.