Created
March 11, 2026 00:26
-
-
Save conholdate-gists/b3b4266f9e6fabdeb39869965702037e 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; | |
| 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