1

I am using TuesPechkin in one of Service Fabric services to generate PDF files from HTML. This is working fine on my local development computer, but as soon as I deploy my application to an Azure cluster and run the same code I get the following error message:

Unable to load DLL 'wkhtmltox.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I think this might be because TuesPechkin relies on the Visual C++ 2013 runtime. Is this supported in a Azure cluster? Or is there something else going wrong?

My code for generating PDF's looks like this:

private static readonly IConverter _converter = new ThreadSafeConverter(
                                                        new PdfToolset(
                                                            new Win64EmbeddedDeployment(
                                                                new AssemblyFolderDeployment())));        

    public Task<byte[]> GeneratePdfFromHtml(string title, string html)
    {            
        try
        {
            var document = new HtmlToPdfDocument
            {
                GlobalSettings = {
                ProduceOutline = true,
                DocumentTitle = title,
                PaperSize = PaperKind.A4, // Implicit conversion to PechkinPaperSize
                Margins = {
                        All = 1.375,
                        Unit = Unit.Centimeters
                    }
                },
                Objects =  {
                new ObjectSettings { HtmlText = html }
                }
            };

            byte[] result = _converter.Convert(document);
            return Task.FromResult(result);
        }
        catch(Exception e)
        {
            throw e;
        }                
    }

AssemblyFolderDeployment.cs

public class AssemblyFolderDeployment : IDeployment
    {
        public string Path
        {
            get
            {
                return System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Wkhtml");
            }
        }
    }
Johannes Heesterman
  • 1,248
  • 1
  • 12
  • 21
  • 2
    did you see the answer to this question? http://stackoverflow.com/questions/38383411/libsodium-64-dll-not-found-in-production-azure-service-fabric-cluster – LoekD Aug 04 '16 at 06:18
  • @LoekD Thanks for pointing that out. I am looking into it. Do you know where I can find this ARM deployment template Tom Davies is referring to? I created the Service Fabric cluster using the Azure Portal. – Johannes Heesterman Aug 04 '16 at 08:59
  • 1
    here are some examples: https://azure.microsoft.com/en-us/documentation/articles/service-fabric-cluster-creation-via-arm/ but you can also go to the Azure Portal -> Resource Explorer and download a template for your existing cluster. – LoekD Aug 04 '16 at 13:22

0 Answers0