Created
March 10, 2026 23:46
-
-
Save conholdate-gists/1ef16db9a7162795f72811ee51532067 to your computer and use it in GitHub Desktop.
How to Convert CDR to PNG using API in .NET
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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