2

Problem

I am trying to create a azure function to create html to pdf. It runs locally perfectly fine but when I deployed it to azure function It shoes me the error

Error

Unable to load DLL 'libwkhtmltox' or one of its dependencies: The specified module could not be found.

Code

public static HttpResponseMessage Run([HttpTrigger(AuthorizationLevel.Function,"post", Route = null)]HttpRequest req, TraceWriter log)
    {
        log.Info("C# HTTP trigger HtmlToPdf processed a request.");

        //string name = req.Query["name"];

        string requestBody = new StreamReader(req.Body).ReadToEnd();
        dynamic data = JsonConvert.DeserializeObject<Body>(requestBody);

        var pdf = Pdf
            .From(data.Html)
            .Content();

        log.Info($"PDF Generated. Length={pdf.Length}");

        var res = new HttpResponseMessage(HttpStatusCode.OK);
        res.Content = new ByteArrayContent(pdf);
        res.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
        res.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("inline");
        return res;
    }
Community
  • 1
  • 1
Malik Kashmiri
  • 5,741
  • 11
  • 44
  • 80

0 Answers0