Help with license file

I just purchased Aspose.Word and am having trouble getting the license file to work. I don’t get any errors per se, but I still get the evaluation message at the top of all the documents I generate with the component. Here is what I have done:

in web.config I have the following:

<add key=“AsposeWordLicense” value=“dev_Aspose.Word.lic” />

then in my document builder file I have:

protected string AsposeWordLicense = ConfigurationSettings.AppSettings[“AsposeWordLicense”];

StreamReader WordLicenseReader = new StreamReader(Server.MapPath(“AsposeLicenses/” + AsposeWordLicense), UnicodeEncoding.UTF7);
Word.SetLicense(WordLicenseReader, this);

Document myAsposeDoc;

// This is a custom object I have written…
clsDocument myDocument = new clsDocument(myDocID);

myAsposeDoc = BuildPolicyDocument(myDocument, UniqueID);
DocExporter.SendToBrowser(myAsposeDoc, myDocument.DocumentName, OutputType, this);

private Document BuildPolicyDocument(clsDocument myDocument, int myUniqueID)
{

//Open the template document

Document myAsposeDoc = OpenDocFromBinary(myDocument.TemplateBinaryData);

// Get policy document data and put into dataset.

clsStoredProcedure mySP = new clsStoredProcedure(myDocument.DocumentType.DataSource);
mySP.AddInteger("@UniqueID", myUniqueID);
DataSet myDS = mySP.ExecuteDataSet(strConn);

myAsposeDoc.MailMerge.RemoveEmptyParagraphs = true;
myAsposeDoc.MailMerge.ExecuteWithRegions(myDS);
myAsposeDoc.MailMerge.DeleteFields();
return myAsposeDoc;

}

private Document OpenDocFromBinary(byte[] myBinaryData)

{

// Create stream from byte array…
MemoryStream myStream = new MemoryStream(myBinaryData, 0, myBinaryData.Length);

// Open the file in Aspose from the stream
Word app = new Word();
return app.Open(myStream);

}


I purchased the product yesterday and then downloaded the new Aspose.Word.dll file today for version 1.8.3. If the code is OK, perhaps this is the problem??

spotvader

Everything seems to be right. If Word.SetLicense does not throw, it means everything should be okay.

I see you open the document from some binary storage, maybe from database? If you used evaluation version of Aspose.Word to put it there in the first place, then the watermark is already there, in the template document. Could it be the case?

The binary version of the file that I open is simply the Word doc template and is uploaded directly from a file uploader control and stored in the database. Aspose is not used at that point. The only time I use Aspose is in the code I posted. Any other ideas what could be causing this?

spotvader

The watermark can only appear in the file when:
1. Word.SetLicense was never called.
2. Word.SetLicense was called with null or empty string (to explicitly set to evaluation mode).

3. The document already had the watermark.

Let's try these:
1. Call Word.SetLicense(Server.MapPath("AsposeLicenses/" + AsposeWordLicense, this). This takes license file name rather than a stream reader. Not sure why would it make a difference, but worthwhile trying.

2. A good way to test if the document in the database already has a watermark in it, comment the call to Word.SetLicense and run your code. If you get two watermarks in the output document - that means you have the document watermarked in the database already.

3. If nothing helps, extract the document from the database and send to word@aspose.com along with the license you are using.