Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

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

Select an option

Save conholdate-gists/1ef16db9a7162795f72811ee51532067 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;
namespace CdrToPngDemo
{
class Program
{
static void Main(string[] args)
{
// Validate arguments
if (args.Length != 2)
{
Console.WriteLine("Usage: CdrToPngDemo <input.cdr> <output.png>");
return;
}
string inputPath = args[0];
string outputPath = args[1];
// Initialize the converter
using var converter = new Conversion(inputPath);
// Configure PNG options
var pngOptions = new PngSaveOptions
{
DpiX = 300,
DpiY = 300,
ColorDepth = PngColorDepth.Depth32Bit,
CompressionLevel = PngCompressionLevel.BestCompression
};
try
{
// Perform the conversion
converter.Convert(outputPath, pngOptions);
Console.WriteLine($"Conversion successful: {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