简体   繁体   中英

Error when generating PDF through NReco PDF Generator

I'm testing out NReco PDF Generator to generate PDF files from C# code. The component have been working well so far, but today I got an exception logged while generating a PDF:

System.Exception: Cannot generate PDF:  (exit code: -1073741628)
 ---> NReco.PdfGenerator.WkHtmlToPdfException:  (exit code: -1073741628)
   at NReco.PdfGenerator.HtmlToPdfConverter.CheckExitCode(Int32 exitCode, String lastErrLine, Boolean outputNotEmpty)
   at NReco.PdfGenerator.HtmlToPdfConverter.InvokeWkHtmlToPdf(PdfSettings pdfSettings, String inputContent, Stream outputStream)
   at NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdfInternal(WkHtmlInput[] htmlFiles, String inputContent, String coverHtml, String outputPdfFilePath, Stream outputStream)
   --- End of inner exception stack trace ---
   at NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdfInternal(WkHtmlInput[] htmlFiles, String inputContent, String coverHtml, String outputPdfFilePath, Stream outputStream)
   at NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdf(String htmlContent, String coverHtml, Stream output)
   at NReco.PdfGenerator.HtmlToPdfConverter.GeneratePdf(String htmlContent, String coverHtml)

Anyone know what could be the cause of this or how I can debug this?

When you see strange exit code like exit code: -1073741628 this means that wkhtmltopdf process is crushed for some reason. To get more details you can:

  • handle "LogReceived" event and get complete wkhtmltopdf console log output; often it contains messages that may help to understand why HTML rendering is failed
  • perform PDF generation from the command line by running wkhtmltopdf for your HTML input

Wkhtmltopdf has some known issues that are not solved and may cause process crush; this might be: too long footer content that goes beyond page dimensions; specific combination of elements with border-radius; specific js code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM