I have successfully gotten both the dll and the activeX to work on my local machine. However when I push to azure a totally dismal story. The dll will load but will not unlock. The activeX will not create comObject.
My environment is Azure Web App, Core 5 and I am developing using the Code editor. It is a development instance but not B1 plan, not shared, 64 bit. The key is a trial key.
This is the entries I included in the the csproj. I confirmed azure deployment includes them in the root with the other compiled dlls and I have even confirmed they are accessible by loading them into memory.
<ItemGroup> <None Update="DebenuPDFLibrary64DLL1811.dll"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </None> <None Update="DebenuPDFLibraryDLL1811.dll"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </None> <None Update="DebenuPDFLibrary64AX1811.dll"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </None> <None Update="DebenuPDFLibraryAX1811.dll"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </None> </ItemGroup>
This is code I use with the dll that works fine locally. On azure it will create an object but instanceId is 0 and of course it will not unlock.
public static string pdfKey = "br549";
public static PDFLibrary newPdfLib() { var pdfLib = new PDFLibrary("./DebenuPDFLibrary64DLL1811.dll"); var result = pdfLib.UnlockKey(pdfKey); return pdfLib;
}
public static void closePdfLib(PDFLibrary pdfLib) { pdfLib.ReleaseLibrary(); }
This is code I am using for ActiveX which doesn't create a new object of the class.
public class PDFLibraryAx { private object comObject; private Type comType;
public static string pdfKey = "br549"; public static bool unlocked = false; public static int renderer = 0; public static string error = "";
public PDFLibraryAx() { try { comType = null; if (IntPtr.Size == 4) { comType = Type.GetTypeFromProgID("DebenuPDFLibraryAX1811.PDFLibrary"); } if (IntPtr.Size == 8) { comType = Type.GetTypeFromProgID("DebenuPDFLibrary64AX1811.PDFLibrary"); } if (comType != null) { comObject = Activator.CreateInstance(comType); } else { error = "comType is null"; } } catch (Exception ex) { error = "bombs at com " + ex.Message; } } }
this is the code that creates the activeX object.
var pdfLib = new Debenu.PDFLibraryAx(); if (pdfLib is object) { Debenu.PDFLibraryAx.unlocked = pdfLib.UnlockKey(Debenu.PDFLibraryAx.pdfKey) == 1; Debenu.PDFLibraryAx.renderer = pdfLib.SelectRenderer(2); if (Debenu.PDFLibraryAx.unlocked) { var ret = pdfLib.LoadFromVariant(fileBytes, Debenu.PDFLibrary.pdfKey);
pdfLib.AddFreeTextAnnotation(100, 200, 300, 30, "Your mama don't dance", 0, 0); pdfLib.AddFreeTextAnnotation(100, 160, 300, 30, "and your daddy don't rock and roll", 0, 0); fileBytes = pdfLib.SaveToVariant(); }
pdfLib.ReleaseLibrary(); pdfLib = null; } else { // "bombs in data, not an object "; } } catch (Exception ex) { // "bombs in data " + ex.Message; }
Hopefully some brainiac, which I obviously am not, will pipe up and save me from this pain. I am shocked searching this site there was only one thread about azure. I had read that debenu will not work on azure because of GDI+ but I haven't gotten that far. I am hopeful if that is an issue using some of the other renderers available will solve that problem. I have used debenu in the past and really like it. Really want it to work.
|