Free Support Forum - aspose.com

Watermark Reappearing on slides

Currently we are using the software to create a risk cube report in Powerpoint. The problem is we inconsistently get a license watermark appearing on the slides even though we DO have a license. We need to stop this watermark from appearing on our slides.
This message was posted using Aspose.Live 2 Forum

Dear lbyrd,

You should set the license in your application load event only once and before you use any of the Aspose.Slides API.

Please show me your code where you are setting license. If you are using Aspose.Slides for JAVA, then are you also using Aspose.Metafiles?

This code is in the Page_Load event.

License license = new License();

try

{

license.SetLicense(Server.MapPath("~/Aspose.Total.lic"));

}

catch (Exception ex)

{

Debug.WriteLine("Trouble with License");

Debug.WriteLine(ex.StackTrace);

}

Please get your code into Global.asax.cs (Global.asax.vb) file, in the Application_Start protected method.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

One thing more, don’t declare the License variable in function scope as you are doing it in function scope, keep it in a class scope and initialize it in your Application start event.

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

You can also make it static for example

class SomeClass : …

{

//Class scope

static License licenseObj;

//Application load event or page load event

void Application_start(….)

{

//licenseObj has been declared in class scope not in function scope

licenseObj.SetLicense(Server.MapPath("~/Aspose.Total.lic"));

}

}

Thanks! I will try this. This problem is not easy to duplicate. Do you know how I can test this to make sure it works? It does not happen all the time.

It did not work for me. What I did was went into my browser, cleared the history, cookies and files. I modified the code and restarted IIS. When I went to the report in my browser, I still get the the watermark. Here is my code in the global.asax.cs:

static Aspose.Slides.License licenseObj = new Aspose.Slides.License();

protected void Application_Start(Object sender, EventArgs e)

{

//License ////////////////////////////////////////////////////////////

//Create a License object

//Aspose.Slides.License license = new Aspose.Slides.License();

try

{

licenseObj.SetLicense(Server.MapPath("~/Aspose.Total.lic"));

}

catch (Exception ex)

{

Debug.WriteLine("Trouble with License");

Debug.WriteLine(ex.StackTrace);

}

//////////////////////////////////////////////////////////////////////

}

Try to move SetLicense call to the method where you create presentation object
and call it before creating Presentation object.
Please check for example our Aspose.Slides.WF.Template asp.net demo.
We call it in the Button1_Click method.

Do you use template presentations in your app?
Make sure you template (if you use it) doesn’t have any watermarks.

Where is that demo located? I found that we are using a template file. When I opened that, there is no watermark on it.

\Program Files\Aspose\Aspose.Slides\Demos\WebForms\Template

I do not have that demo. This is really getting frustrating.

Download Aspose.Slides.msi installer from here and install it.
May be Aspose.Total installer put demos to another folder.

I’ve viewed the template code. In that code the license variable is NOT declared in the global.asax. It is declared in the button1_click. It is used exactly like mine was previously except it is before the declaration of the presentation object. Should that fix it? Or will the variable still have to be in the global.asax.cs file? If it still has to be in the global file, how will I reference it in my other code page?

Sure, if you call SetLicense before declaration of Presentation object it should fix the problem.

To sum it up:

  1. Move the declaration of the license variable out of the global.asax.cs back to the code page outside of the function.
  2. Call the SetLicense method just before creating the presentation object.

Correct? Is there a way to duplicate this error consistently that you know of so I can make sure this fix works? Currently I can not consistently make it reoccur.