许可| Aspose.Page 提供 .NET
评估版本限制
我们希望客户在购买之前对我们的组件进行彻底测试,以便评估版本可以像通常一样使用它。但是,未经许可的产品:
- 允许转换大小不超过500 kb的PostScript文件,在这种情况下,由此产生的PDF文档将包含评估标记。
- 不允许操纵超过4个XPS元素,在这种情况下,由此产生的文档或图像也将包含评估标记。
经典许可
可以从文件或流对象加载许可证。 设置许可证的最简单方法是将许可证文件与Aspose.page.dll文件放在同一文件夹中,并指定文件名,没有路径,如下示例所示。
从文件中加载许可证
应用许可证的最简单方法是将许可证文件与aspose.page.dll文件放在同一文件夹中,并仅指定没有路径的文件名。
如果您使用的是使用任何其他Aspose。
1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
2// The path to the documents directory.
3string dataDir = RunExamples.GetDataDir_GettingStarted();
4// Initialize license object
5License license = new License();
6// Set license
7license.SetLicense("D:\\Aspose.Total.NET.lic");
8Console.WriteLine("License set successfully.");
当您调用setlicense方法时,您通过的许可名称应为您的许可证文件。例如,如果将许可证文件名称更改为“ aspose.page.lic.xml”,则将该文件名传递给许可证.setlicense.setlicense(…)方法。
从流对象加载许可证
以下示例显示了如何从流中加载许可证。
1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
2// The path to the documents directory.
3string dataDir = RunExamples.GetDataDir_GettingStarted();
4// Initialize license object
5Aspose.Page.License license = new Aspose.Page.License();
6// Load license in FileStream
7FileStream myStream = new FileStream("Aspose.Total.NET.lic", FileMode.Open);
8// Set license
9license.SetLicense(myStream);
10Console.WriteLine("License set successfully.");
使用AS嵌入式资源
要应用许可证,您可以从文件或流中加载它。将许可证包装在您的应用程序中的另一种整洁的方式是将其作为嵌入式资源包含在一个呼叫Aspose.net页面的程序集中。
将文件作为嵌入式资源包括:
- 在Visual Studio .NET中,通过单击文件菜单并选择添加现有项目,将.lic文件包括在项目中。
- 在解决方案资源管理器中选择文件。
- 在属性窗口中,将构建操作设置为嵌入式资源。
MERGEDAPI是应用程序的默认名称空间。
1// For complete examples and data files, please go to https://github.com/aspose-xps/Aspose.XPS-for-.NET
2// The path to the documents directory.
3string dataDir = RunExamples.GetDataDir_GettingStarted();
4// Initialize license object
5Aspose.Xps.License license = new Aspose.Xps.License();
6// Set license
7license.SetLicense("MergedAPI.Aspose.Total.lic");
8// Set the value to indicate that license will be embedded in the application
9license.Embedded = true;
10Console.WriteLine("License set successfully.");
需要考虑的一个点 - 请注意,嵌入式资源包含在汇编中,即添加它们的方式,即如果将文本文件作为应用程序中的嵌入式资源添加,并在Notepad中打开所得的EXE,您将看到文本文件的确切内容。因此,当使用许可证文件作为嵌入式资源时,任何人都可以在一些简单的文本编辑器中打开.EXE文件,并查看/提取嵌入式许可证的内容。
因此,为了在将许可证与应用程序嵌入许可证时放置额外的安全层,您可以压缩/加密许可证,此后,您可以将其嵌入到程序集中。免费的实用程序dotnetzip( http://dotnetzip.codeplex.com/)可以帮助满足这一要求。假设我们有Aspose.total.net.lic许可证文件,所以让我们将Aspose.total.net.lic.zip与密码测试进行,然后将此ZIP文件嵌入解决方案中。以下代码段可用于初始化许可证:
1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
2// The path to the documents directory.
3string dataDir = RunExamples.GetDataDir_GettingStarted();
4// Initialize license object
5Aspose.Page.License license = new Aspose.Page.License();
6// Set license
7license.SetLicense("MergedAPI.Aspose.Total.NET.lic");
8// Set the value to indicate that license will be embedded in the application
9license.Embedded = true;
10Console.WriteLine("License set successfully.");
计量许可证
aspose.page允许开发人员应用计量密钥。这是一种新的许可机制。新的许可机制将与现有许可方法一起使用。那些希望根据API功能使用的客户可以使用计量许可的客户。有关更多详细信息,请参阅 计量许可常见问题解答部分。
已经引入了一个新的计量级计量来应用计量密钥。以下是示例代码,演示了如何设置计量的公共和私钥。
1// set metered public and private keys
2Aspose.Page.Metered metered = new Aspose.Page.Metered();
3// Access the setMeteredKey property and pass public and private keys as parameters
4metered.SetMeteredKey(
5 "<type public key here>",
6 "<type private key here>");