6

We are using ironPDF to convert our document into PDF, it was working fine and was converting our documents (HTML) to PDF seamlessly in localhost, and after confirming everything we have bought a license of 1 year and uploaded the code to Production.

As soon as we have uploaded our code in Production, we are getting an error: access to the path 'IronPdf.ChromeRenderingEngine.dll' is denied.

Here is the code that we are using

   string file = $"{Guid.NewGuid().ToString().Replace("-", "")}.pdf";
   IronPdf.License.LicenseKey = ConfigurationManager.AppSettings["IronPdf.LicenseKey"];
   IronPdf.Installation.TempFolderPath = ironPdf;
   var pdfPrintOptions = new PdfPrintOptions()
   {
       InputEncoding = Encoding.UTF8,
       PaperOrientation = PdfPrintOptions.PdfPaperOrientation.Portrait,
       MarginTop = 10,
       MarginBottom = 10,
       MarginLeft = 10,
       MarginRight = 10,
       Footer = new SimpleHeaderFooter()
       {
           RightText = "Page {page} of {total-pages}",
           DrawDividerLine = true,
           FontSize = 10,
           FontFamily = "Open Sans"
       },
       CssMediaType = PdfPrintOptions.PdfCssMediaType.Print
   };
   var Renderer = new HtmlToPdf(pdfPrintOptions);
   var PDF = Renderer.RenderHtmlAsPdf(htmlContent.ToString());
   PDF.SaveAs($"{sourceUrl}{file}");
   PDF.Dispose();
Chandresh Khambhayata
  • 1,748
  • 2
  • 31
  • 60
  • I just got the same error today after purchasing and installing the license key. If i revert back to the trial license key, which worked a minute ago, i still get the same error – mlg74 Sep 23 '20 at 19:13
  • I restarted my server and it worked, but now the watermark is on the PDF. If i make any change, I get the error again, but then have to restart, but still have watermark – mlg74 Sep 23 '20 at 20:50
  • Yes, in free version it is working without any issue, but the problem is with Watermark. – Chandresh Khambhayata Sep 24 '20 at 05:07
  • Delete the dll, delete temporary files on server, do a clean install. Take license out of your web.config or app.config and initialize it before each instance you use it. Worked for me. – mlg74 Sep 24 '20 at 06:49

1 Answers1

7

I had the same problem as this. I managed to solve it by setting the temp folder path to a location that the code could reach and write to (I believe it unpacks the libraries to it when it performs the generation). This is especially relevant when you're using an application service such as Azure or AWS.

For ASP.NET applications I put this in Application_Start() in global.ascx.cs:

IronPdf.Installation.TempFolderPath = Server.MapPath(@"/tmp");

For .NET Core I put this in Startup constructor.

IronPdf.Installation.TempFolderPath = @"/tmp";
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mjbates7
  • 674
  • 1
  • 6
  • 15
  • 3
    Link to documentation for IronPdf.Installation.TempFolderPath https://ironpdf.com/object-reference/api/IronPdf.Installation.html#IronPdf_Installation_TempFolderPath – Stephanie Jul 13 '21 at 02:48