Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save conholdate-gists/b3b4266f9e6fabdeb39869965702037e to your computer and use it in GitHub Desktop.

Select an option

Save conholdate-gists/b3b4266f9e6fabdeb39869965702037e 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()
{
// Paths
string inputPath = @"C:\Docs\sample.cdr";
string outputPath = @"C:\Docs\sample.png";
try
{
// Initialize conversion
var conversion = new Conversion(inputPath);
// Set PNG options
var pngOptions = new PngOptions
{
Resolution = 300,
BackgroundColor = System.Drawing.Color.White,
CompressionLevel = 9
};
// Add output format
conversion.AddOutput(pngOptions, outputPath);
// Perform conversion
conversion.Convert();
Console.WriteLine("Conversion successful. PNG saved to: " + outputPath);
}
catch (ConversionException ex)
{
Console.Error.WriteLine("Conversion failed: " + ex.Message);
}
catch (Exception ex)
{
Console.Error.WriteLine("Unexpected error: " + ex.Message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment