This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/dotnet/load-a-file/imaging/from-byte-array-svg.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Load a vector image (SVG) from byte array in C# .NET | Nutrient .NET SDK
SVG

To load an SVG image from a byte array, use the CreateGdPictureImageFromByteArray method of the GdPictureImaging class.

This method returns a non-zero GdPicture image identifier (imageID) on success. If it fails, it returns 0 — use GetStat() to view the failure reason.

Overloads:

  • CreateGdPictureImageFromByteArray(byte[] Data)
  • CreateGdPictureImageFromByteArray(byte[] Data, DocumentFormat ImageFormat)

For SVG data, the default overload is typically used so the toolkit auto-detects the format from content.

When you no longer need the image resource, release it with the ReleaseGdPictureImage method.

To load an SVG image from a byte array, use the following code:

using GdPicture14;
using System;
using System.IO;
using GdPictureImaging gdpictureImaging = new GdPictureImaging();
// Create a byte array from an SVG file.
byte[] byteArray = File.ReadAllBytes(@"C:\temp\source.svg");
// Create a GdPicture image from the byte array.
int imageID = gdpictureImaging.CreateGdPictureImageFromByteArray(byteArray);
if (imageID == 0)
{
Console.WriteLine($"CreateGdPictureImageFromByteArray failed: {gdpictureImaging.GetStat()}");
return;
}
GdPictureStatus status = gdpictureImaging.SaveAsPNG(imageID, @"C:\temp\output.png");
if (status != GdPictureStatus.OK)
{
Console.WriteLine($"SaveAsPNG failed: {status}");
}
gdpictureImaging.ReleaseGdPictureImage(imageID);