许可 – Licensing – Aspose.SVG for .NET
评估版限制
可以从 Aspose 网站的下载部分下载 Aspose.SVG for .NET 的免费评估版本: Download Aspose.SVG API。
局限性
评估版提供除以下功能之外的所有功能:
- 水印添加到输出文件中。
- 只能转换 SVG 文档的前四页。
- 序列化期间仅保存 50% 的 SVG 文档节点。
如果您想在没有评估限制的情况下尝试 Aspose.SVG,请请求 30 天的临时许可证。请参阅 How to get a Temporary License? 了解更多信息。
使用文件或流对象应用许可证
可以从文件 或流对象 加载许可证。 Aspose.SVG for .NET 将尝试在以下位置查找许可证:
- 显式路径。
- 包含Aspose.SVG.dll的文件夹。
- 包含名为 Aspose.SVG.dll 的程序集的文件夹。
- 包含入口程序集(您的 .exe)的文件夹。
- 程序集中的嵌入资源,称为 Aspose.SVG.dll。
设置许可证的最简单方法是将许可证文件放在与 Aspose.SVG.dll 文件相同的文件夹中,并指定文件名(不带路径),如下例所示。
如果您将任何其他 Aspose for .NET API 与 Aspose.SVG for .NET 一起使用,请指定许可证的命名空间,例如 Aspose.ThreeD.License。
从文件加载许可证
应用许可证的最简单方法是将许可证文件放在与 Aspose.SVG.dll 文件相同的文件夹中,并仅指定文件名而不指定路径。
当您调用 SetLicense 方法时,您传递的许可证名称应该是许可证文件的名称。例如,如果您将许可证文件名更改为“Aspose.SVG.lic.xml”,则将该文件名传递给 ThreeD.SetLicense(…) 方法。
例子:
1// Initialize a license object
2Aspose.Svg.License svgLicense = new Aspose.Svg.License();
3
4// Apply the license using a file name
5svgLicense.SetLicense("Aspose.SVG.lic");
从流对象加载许可证
以下示例显示如何从流加载许可证。
1// Initialize a license object
2Aspose.Svg.License svgLicense = new Aspose.Svg.License();
3
4// Open a license file stream
5using (var stream = new System.IO.FileStream("Aspose.SVG.lic", System.IO.FileMode.Open))
6{
7 // Apply the license using the stream
8 svgLicense.SetLicense(stream);
9}
使用嵌入式资源申请许可证
应用许可证的一种方法是使用文件或流对象进行设置。将许可证与应用程序打包并确保其不会丢失的另一种巧妙方法是将其作为嵌入式资源包含到调用组件的 DLL(包含在 Aspose.SVG 中)的程序集中。
要将许可证文件包含为嵌入资源:
- 在 Visual Studio .NET 中,通过选择 File、Add Existing Item 和最后 Add,将许可证 (.lic) 文件包含到项目中。
- 在解决方案资源管理器中选择文件。
- 在属性窗口中将 Build Action 设置为 Embedded Resource。
- 要访问程序集中嵌入的许可证(作为嵌入资源),只需将许可证文件作为嵌入资源添加到项目中,并将许可证文件的名称传递给 SetLicense 方法即可。 License 类会自动在嵌入资源中查找许可证文件。无需调用 Microsoft .NET Framework 中 System.Reflection.Assembly 类的 GetExecutingAssembly 和 GetManifestResourceStream 方法。
以下代码片段用于设置许可证。
1// Initialize a license object
2Aspose.Svg.License svgLicense = new Aspose.Svg.License();
3
4// Apply the license using the embedded resource name
5svgLicense.SetLicense("Aspose.SVG.lic");
申请计量许可证
Aspose.SVG for .NET API 允许开发人员应用计量许可证。这是一种新的许可机制。新的发牌机制将与现有的发牌方法同时使用。想要根据 API 功能的使用情况进行计费的客户可以使用计量许可。有关更多详细信息,请参阅 Metered Licensing FAQ 部分。
添加了新的类 Metered 以应用计量密钥。此代码示例演示如何设置计量公钥和私钥:
1// Initialize a metered object
2Aspose.Svg.Metered metered = new Aspose.Svg.Metered();
3
4// Apply the metered license using the public and private keys
5metered.SetMeteredKey("*****", "*****");