问题
I am trying to generate pdf using nreco library and i am getting this exception while generating.
(exit code: -1073741819) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: NReco.PdfGenerator.WkHtmlToPdfException: (exit code: -1073741819) Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [WkHtmlToPdfException: (exit code: -1073741819)] NReco.PdfGenerator.HtmlToPdfConverter.CheckExitCode(Int32 exitCode, String lastErrLine, Boolean outputNotEmpty) +134 NReco.PdfGenerator.HtmlToPdfConverter.InvokeWkHtmlToPdf(PdfSettings pdfSettings, String inputContent, Stream outputStream) +644 NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdfInternal(WkHtmlInput[] htmlFiles, String inputContent, String coverHtml, String outputPdfFilePath, Stream outputStream) +1282
require assistance.
回答1:
This error (like "exit code: -1073741819") means that wkhtmltopdf process was crushed. Possible reasons:
- wkhtmltopdf executable is incompatible with the OS. Say, MSVC build - which is shipped in NReco.PdfGenerator nuget package - doesn't support legacy Windows versions like XP or 2003 Server (workaround is using MingGW build). Or if windows executable is used with Linux or Mac OS environment (solution is using NReco.PdfGenerator.LT nuget + deploy/install correct wkhtmltopdf binaries for the target platform).
- missed required Universal C runtime libs ( https://support.microsoft.com/en-us/help/2999226/update-for-universal-c-runtime-in-windows ). This is rare case, as usually these libs are already installed by Windows Update.
- if this error occurs only for concrete HTML this might be a problem with complex HTML layout or heavy JS script. For example, wkhtmltopdf 0.12.4 can crush when ChartsJS library is used by the page (workaround exists).
来源:https://stackoverflow.com/questions/48678977/nreco-pdf-genreation-error-dot-net