Skip to content

Instantly share code, notes, and snippets.

@groupdocs-cloud-gists
Last active July 23, 2024 00:27
Show Gist options
  • Save groupdocs-cloud-gists/cb2a1187fe5b5a30272eeddb8f5508d0 to your computer and use it in GitHub Desktop.
Save groupdocs-cloud-gists/cb2a1187fe5b5a30272eeddb8f5508d0 to your computer and use it in GitHub Desktop.
convert SVG to JPG

Scalable Vector Graphics to JPG Conversion with C# .NET


Let's explore a step-by-step process and practical code examples to help you seamlessly transform your SVG images into high-quality JPGs. Dive in and learn how to harness the power of GroupDocs.Conversion Cloud SDK for efficient and effective image processing. This conversion is performed is performed using GroupDocs.Conversion Cloud SDK for .NET.



For more details, please visit Convert SVG to JPG in C# .NET.

svg to jpg

Important Links

Product Page | Docs | Live Demo | API Reference | Code Samples | Source Code | New Releases | Blog | Free Support | Free Trial

Learn how to convert SVG to JPG using C# .NET
// More examples over https://github.com/groupdocs-conversion-cloud/groupdocs-conversion-cloud-dotnet
// Obtain your API credentials
string clientId = "XXXXXXX-XXXXXXX-4088-XXXXX-55c38f4b7f22";
string clientSecret1 = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
// Create an instance of the Configuration class and initialize it with the Client ID & Client Secret.
var configurations = new Configuration(clientId, clientSecret1);
// Define the value of ApiBaseUrl to set the base url for SVG to JPG conversion API.
configuration.ApiBaseUrl = "https://api.groupdocs.cloud";
// Initialize an instance of the ConvertApi class with the object of the Configuration class.
var apiInstance = new ConvertApi(configurations);
// read the content of input SVG image from local drive
using (var stream = System.IO.File.OpenRead("input.svg"))
{
// create an instance of FileApi
var fileUpload = new FileApi(configurations);
// upload the input SVG to the cloud storage
fileUpload.UploadFile(new UploadFileRequest("input.svg", stream));
// create ConvertSettings where we define the input SVG file name and the name of resultant JPG image
var settings = new ConvertSettings
{
StorageName = "default",
FilePath = "input.svg",
Format = "jpg",
OutputPath = "myResultant.jpg"
};
// Invoke the ConvertDocument method to transform SVG to JPG format
var response = apiInstance.ConvertDocument(new ConvertDocumentRequest(settings));
if (response != null && response.Equals("OK"))
{
// print success message
Console.WriteLine("The SVG to JPG conversion completed successfully !");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment