We have lisences for Aspose.Pdf and Aspose.Words. This is how the licenses are set in the constructor of the class:
Aspose.Pdf.License pdfLicense = new Aspose.Pdf.License();
pdfLicense.SetLicense("Aspose.Custom.lic");
Aspose.Words.License wordLicense = new Aspose.Words.License();
wordLicense.SetLicense("Aspose.Custom.lic");
However, when a method residing in the same class is called, the null reference exeption is thrown. If I comment out the part that sets up Aspose.Words lisence, no exception is thrown but the generated PFD has garbage text inserted by Aspose.Words.
Here is the body of the method (lisences are set up in the constructor before the method is called):
private static byte[] GeneratePdf(Aspose.Words.Document doc)
{
try
{
MemoryStream stream = new MemoryStream();
doc.Save(stream, SaveFormat.FormatAsposePdf);
stream.Seek(0, SeekOrigin.Begin);
Aspose.Pdf.Pdf pdf = new Pdf();
pdf.IsImagesInXmlDeleteNeeded = true;
pdf.BindXML(stream, null);
MemoryStream ms = new MemoryStream();
pdf.Save(ms); // this line throws an exception if lisence for Aspose.Words is set.
return ms.GetBuffer();
}
catch (Exception ex)
{
return null;
}
}
Exception source: Aspose.Pdf
Exception message: Object reference not set to an instance of an object.
Can it be that the lisence is invalid or we are missing something here?