IronPDF Renderer.RenderHtmlAsPdf failing when deployed to IIS

979 Views Asked by At

We are using ironPDF to genetate PDF file from HTML string. It is a MVC web application written in C# (.net framework 4.8) , deployed to IIS

I did the following.

  1. Added IronPdf nuget package to the project (Version: 2022.11.10347)

  2. Use the following code to generate PDF from string

using IronPdf; (on top of the code to add ref)

PDF generation code as below;

public ActionResult ExportPDF()

{

var Renderer = new IronPdf.ChromePdfRenderer();

var pdfDoc = Renderer.RenderHtmlAsPdf(htmlstring);

return File(pdfDoc.Stream.ToArray(), "application/pdf", "TransactionStatement.pdf");

}

here htmlstring is the html that need to be rendered to PDF

This code works fine and generates PDF when I run in my local dev machine.

But when I deploy this code to our integration environment , it is failing. It is not generating any PDF.

It just hangs for couple of minutes then our website is getting timed out and application pool is getting stopped.

the failure is happening is in the following line

 var pdfDoc = Renderer.RenderHtmlAsPdf(htmlstring); 

Out integration environment is in IIS (Windows server 2008 R2) . and application pool identity is NetworkService. applicationpool

When I looked into the event log I can see the following warnings

Application popup: IronCefSubprocess.exe - System Error : The program can't start because api-ms-win-core-com-l1-1-0.dll is missing. from your computer. Try reinstalling the program to fix this problem. 

A process serving application pool '<poolname>' suffered a fatal communication error with the Windows Process Activation Service. The process id was '5940'. The data field contains the error number.

I have all required Visual C++ redistributables installed in my server as described in the ironPDF website enter image description here

Any idea how to fix this issue.

1

There are 1 best solutions below

0
On

For API-MS-WIN-CORE-COM-L1-1-0.DLL. You could refer to this to reinstall API-MS-WIN-CORE-COM-L1-1-0.DLL.

About application pool error. As the community member said, need configuration information is needed to locate the cause.

In my opinion, you could try turn Enable 32-bit applications to true. If still don't work, you can refer to this using debugging tools to locate the cause.