Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-gists/7edca032f84b937c8289e25861dd7f1f to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/7edca032f84b937c8289e25861dd7f1f to your computer and use it in GitHub Desktop.
How to Convert CDR to PNG using API in .NET
using System;
using Conholdate.Total;
using Conholdate.Total.Conversion;
using Conholdate.Total.Conversion.Options;
class Program
{
static void Main()
{
// Path to the source CDR file
string inputPath = @"C:\Docs\sample.cdr";
// Path for the generated PNG file
string outputPath = @"C:\Docs\sample.png";
// Initialize the converter
using var converter = new Converter();
try
{
// Load the CDR document
converter.LoadDocument(inputPath);
// Set PNG export options
var pngOptions = new PngOptions
{
ResolutionX = 300,
ResolutionY = 300,
BitDepth = 24,
Transparency = true
};
// Perform the conversion
converter.Convert(outputPath, pngOptions);
Console.WriteLine("Conversion successful. PNG saved to: " + outputPath);
}
catch (ConversionException ex)
{
Console.WriteLine("Error during conversion: " + ex.Message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment