Created
March 10, 2026 20:48
-
-
Save conholdate-gists/7380f6738191770b063d625fa48ee0eb 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; | |
| namespace CdrToPngDemo | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| // Validate input arguments | |
| if (args.Length < 2) | |
| { | |
| Console.WriteLine("Usage: CdrToPngDemo <input.cdr> <output.png>"); | |
| return; | |
| } | |
| string inputPath = args[0]; | |
| string outputPath = args[1]; | |
| try | |
| { | |
| // Initialize the conversion engine | |
| var converter = new Conversion(); | |
| // Load the CDR document | |
| converter.LoadDocument(inputPath); | |
| // Configure PNG output options | |
| var pngOptions = new PngOptions | |
| { | |
| DpiX = 300, | |
| DpiY = 300, | |
| BackgroundColor = System.Drawing.Color.White | |
| }; | |
| // Execute conversion | |
| converter.Convert(outputPath, pngOptions); | |
| Console.WriteLine($"Conversion successful: {outputPath}"); | |
| } | |
| catch (Exception 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