0

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.

Prasanth
  • 31
  • 3
  • 9
  • 1
    `pdfDoc.Stream.ToArray()` <-- Don't do this. You can pass the `pdfDoc.Stream` directly to ASP.NET's response methods - Using `ToArray` means needlylessly wasting memory and CPU by allocating and copying PDF data at least 3 times there. – Dai Dec 04 '22 at 20:23
  • The error is because you haven't done a publish-deploy of your application correctly. It looks like you just copied your `bin` output dir to IIS: you can't do that because it won't include all necessary dependencies. Use the "Publish to Folder" step instead. – Dai Dec 04 '22 at 20:25
  • @Dai It is proper buld and deploy using Jenkins and octopus deploy. – Prasanth Dec 04 '22 at 20:32
  • Then that means your Jenkins/Octopus set-up is not including all necessary dependencies. Are you using NuGet/`` to use IronPDF? Or doing it manually? – Dai Dec 04 '22 at 20:34
  • @Dai using nuget – Prasanth Dec 04 '22 at 20:42
  • Please post your `.csproj`, your `.targets` and `.props`, and your `.publish.xml`, and your Jenkins+Octopus configs. – Dai Dec 04 '22 at 20:43
  • Your Control Panel screenshot suggests you've been running the same OS instance since 2013... you **really** should consider doing a clean build at this point: every machine will accumulate cruft over time. – Dai Dec 04 '22 at 20:54
  • Were you able to figure this out? I'm having the same issue with Windows Server 2012 R2. My staging/dev environment is Windows Server 2019 and has no issue. – Brett.J Feb 24 '23 at 23:47
  • No.. I have re-written the code using another library. Unfortunately I didn't get proper technical support from iron pdf team – Prasanth Feb 26 '23 at 09:07

1 Answers1

0

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.

TengFeiXie
  • 176
  • 5