Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running IronPDF on AWS Lambda - Can't Unpack Binaries to /tmp (.NET/C#)

I'm trying to run a simple proof of concept running IronPDF on an AWS lambda. The code deploys fine, but upon invocation IronPDF can't unpack the binaries needed for Chromium to render my PDF.

IronPDF Installation Docs

I am using serverless + csharp template and the function invoked fine before adding IronPDF.

I've tried to manually set the installation directory, but I get a permssion error:

"IronPdf.Installation.TempFolderPath currently set to '/tmp' but has insufficient user permissions for deployment.\nPlease check that this directory exists and full permissions are granted for the current application user"

As far as I know, AWS lambda user has full permissions to "/tmp", but I've never ran a .NET lambda before.

EDIT: I was able to write a text file to /tmp without issue.

       public Response Hello(Request request)
       {
         IronPdf.Installation.TempFolderPath = @"/tmp";

         IronPdf.HtmlToPdf Renderer = new IronPdf.HtmlToPdf();
         var PDF = Renderer.RenderHtmlAsPdf("<h1>Hello from DocThread</h1>");
         PDF.SaveAs("/tmp/sample.pdf");

         return new Response("Go Serverless v1.0! Your function executed successfully!", request);
       }

Lastly, I imagine that this is just an issue of me being new to C#/.NET on AWS Lambda. It's a fairly common pattern to write files to /tmp before uploading to S3.

Thanks in advance for the help!

like image 589
igolden Avatar asked Oct 26 '25 10:10

igolden


1 Answers

I was fighting this issue also, and I just figured it out. Here is what I did:

  • Run IronPDF locally and set the TempFolderPath to a directory that you can find quickly. IronPdf will unpack the necessary files (two .dll, a .dylib, and a .so) to this directory.
  • Find the unpacked files in the TempFolderPath set above and copy IronPdf_ChromeRenderingEngine.so to the root of the Lambda project.
  • In Visual Studio, set the Build Action to Content in the properties tab for the .so
  • In Visual Studio, set the Copy to Output Directory to Copy if newer in the properties tab for the .so
  • Add Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + ":" + Environment.GetEnvironmentVariable("LAMBDA_TASK_ROOT")); to the constructor for the Lambda.
  • Set IronPdf.Installation.TempFolderPath = @"/tmp";

I also set my MemorySize to 512 and Timeout to 180 in the serverless.template, because I was maxing out on Memory at 256.

I hope this makes sense and helps you solve your issue!

like image 53
Matthew Zagone Avatar answered Oct 29 '25 00:10

Matthew Zagone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!