Created
March 12, 2026 15:52
-
-
Save conholdate-gists/6bf5d57ccbf49c02f06c53a8a4b94e89 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) | |
| { | |
| // Paths – update these to match your environment | |
| string inputPath = "sample.cdr"; | |
| string outputPath = "sample.png"; | |
| try | |
| { | |
| // 1. Create conversion engine | |
| var engine = new ConversionEngine(); | |
| // 2. Load the CDR file | |
| var document = engine.Load(inputPath); | |
| // 3. Set PNG export options | |
| var pngOptions = new PngExportOptions | |
| { | |
| Resolution = 300, // 300 DPI for high quality | |
| CompressionLevel = 6, // Medium compression | |
| BackgroundColor = System.Drawing.Color.White | |
| }; | |
| // 4. Convert and save as PNG | |
| document.Save(outputPath, pngOptions); | |
| Console.WriteLine($"Conversion successful: {outputPath}"); | |
| } | |
| catch (ConversionException ex) | |
| { | |
| Console.WriteLine($"Conversion failed: {ex.Message}"); | |
| // Additional logging can be added here | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment