In my ASP.NET application (.NET Framework 4.7) I'm using OpenHtmlToPdf
for creating PDF based on the pages in the website.
It is working locally but not in the server production: I have the following error:
Exception type: System.ComponentModel.Win32Exception Exception message: Access is denied
Stack trace: at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at OpenHtmlToPdf.HtmlToPdfConverterProcess.Convert(ConversionSource conversionSource) at OpenHtmlToPdf.Pdf.DocumentBuilder.ReadContentUsingTemporaryFile(String temporaryFilename)
I think the problem is related to wkhtmltopdf
because OpenHtmlToPdf is using this library to generate the PDF. The code is pretty simple.
var pdf = Pdf.From(html)
.WithGlobalSetting("orientation", "Landscape")
.WithObjectSetting("web.defaultEncoding", "utf-8")
.Content();
return File(pdf, System.Net.Mime.MediaTypeNames.Application.Octet, "Reference.pdf");
Then, how can I generate the PDF?