Convert CDR to PDF in C#
Contents
[
Hide
]
Using C# Image Processing Library Aspose.Imaging, we can convert single or multipage CDR file to PDF.
The following code snippet shows you how to convert CDR to Pdf.
This file contains 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 Aspose.Imaging; | |
using Aspose.Imaging.ImageOptions; | |
using System.IO; | |
string templatesFolder = @"c:\Users\USER\Downloads\templates\"; | |
string dataDir = templatesFolder; | |
using (var image = (VectorMultipageImage)Image.Load(dataDir + "template.cdr")) | |
{ | |
// Create page rasterization options | |
VectorRasterizationOptions[] pageOptions = new VectorRasterizationOptions[image.PageCount]; | |
for (int i = 0; i < image.PageCount; i++) | |
{ | |
CdrRasterizationOptions option = new CdrRasterizationOptions(); | |
option.PageSize = image.Pages[i].Size; | |
pageOptions[i] = option; | |
} | |
// Create PDF options | |
var options = new PdfOptions { MultiPageOptions = new MultiPageOptions { PageRasterizationOptions = pageOptions } }; | |
// Export image to PDF format | |
image.Save(dataDir + "result.pdf", options); | |
} | |
File.Delete(dataDir + "result.pdf"); |