Aspose.SVG for .NET

探索Aspose.SVG for .NET库,实现SVG文件的灵活处理、高效转换及图像矢量化,支持多种格式合并与编辑。

Aspose.SVG for .NET是一个灵活的 SVG 文件处理库,完全兼容其规范。API 可以轻松加载、保存和转换 SVG 文件,并通过其文档对象模型 (DOM) 读取和遍历文件元素。API 独立于任何其他软件,使开发人员无需深入了解 SVG 格式的底层细节即可处理 SVG 文件。

Aspose.SVG for .NET API 的高级功能


使用 XPath 查询导航 SVG

通过 CSS 选择器、元素和文档遍历进行导航

C# 库函数的有用文档链接


使用 C# 转换 SVG

Aspose.SVG for .NET可以读取 SVG 并将其转换为 PDF、XPS 和主流图像格式。转换过程简单可靠,因此 SVG .NET API 是您的不二之选。您可以在 C# 或任何其他 .NET 应用程序中使用 API 来开发转换器应用程序,而无需了解底层文件格式的细节。转换功能的实现非常简单,具体取决于每个应用程序的需求。以下是几行用于格式转换的代码。

将 SVG 转换为 PNG – C#

using Aspose.Svg;using System.IO;using Aspose.Svg.Saving;using Aspose.Svg.Converters;...
    // Initialize an SVG document from a file
    using (var document = new SVGDocument("input.svg"))
    {
    	// Create an instance of the ImageSaveOptions class
    	var pngSaveOptions = new ImageSaveOptions();
        // Convert SVG to PNG
    	Converter.ConvertSVG(document, pngSaveOptions, "output.png");
    }

您可以通过链接尝试在线SVG 转换器。

其他支持的 SVG 转换:

将光栅图像转换为矢量图形

使用 Aspose.SVG API 将图像转换为矢量非常容易。ImageVectorization命名空间包含用于实现图像矢量化过程的类和接口。以下代码片段演示了如何使用 ImageVectorizer 类进行图像矢量化:

将图像转换为矢量 – C#

using Aspose.Svg.ImageVectorization;using Aspose.Svg.Saving;...
	// Initialize an instance of the ImageVectorizer class
	var vectorizer = new ImageVectorizer
	{
		Configuration = 
		{
			TraceSmoother =   new ImageTraceSmoother(1),
			TraceSimplifier = new ImageTraceSimplifier(0.5f),
			ColorsLimit = 3
		}
	};
	// Vectorize raster image from the specified file
	using var document = vectorizer.Vectorize("input.png");
	// Save vectorized image as SVG file 
	document.Save("output.svg");

您可以尝试免费的在线图像矢量化器。

其他支持的矢量化器:

在 C# 中合并 SVG

Renderer() 方法允许您一次性将多个文档发送到输出渲染设备并进行合并。文档合并只需几行代码即可完成:

将 SVG 合并为 PDF – C#

using Aspose.Svg;using Aspose.Svg.Rendering;using Aspose.Svg.Rendering.Pdf;...
	// Initialize SVG documents from files to merge later
	using (var document1 = new SVGDocument("input1.svg"))	using (var document2 = new SVGDocument("input2.svg"))	using (var document3 = new SVGDocument("input3.svg"))
	{
		// Create an instance of SvgRenderer
		using (var renderer = new SvgRenderer())
		{
			// Create an instance of PdfDevice
			using (var device = new PdfDevice("output.pdf"))
			{
				// Merge all SVG documents to PDF
				renderer.Render(device, document1, document2, document3);
			}
		}
	}

其他支持的合并:


产品推荐

  • 账号登录
社交账号登录