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");
}
}
}