public static void Run() { //ExStart:ExportToBMP // The path to the documents directory. string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string fileName = GetFileFromDesktop("APFH Floor Plan.dwf"); using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(fileName)) { BmpOptions bmpOptions = new BmpOptions(); var dwfRasterizationOptions = new DwfRasterizationOptions(); bmpOptions.VectorRasterizationOptions = dwfRasterizationOptions; dwfRasterizationOptions.CenterDrawing = true; dwfRasterizationOptions.PageHeight = 500; dwfRasterizationOptions.PageWidth = 500; dwfRasterizationOptions.Layouts = new string[] { "Model" }; // export string outPath = fileName + ".bmp"; image.Save(outPath, bmpOptions); } //ExEnd:ExportToBMP Console.WriteLine("\n3D images exported successfully to PDF.\nFile saved at " + MyDir); }
public static void Run() { //ExStart:ConvertDrawingToRasterImage // The path to the documents directory. string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) { // Create an instance of CadRasterizationOptions Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); // Set page width & height rasterizationOptions.PageWidth = 1200; rasterizationOptions.PageHeight = 1200; // Create an instance of PngOptions for the resultant image ImageOptionsBase options = new Aspose.CAD.ImageOptions.PngOptions(); //Set rasterization options options.VectorRasterizationOptions = rasterizationOptions; MyDir = MyDir + "conic_pyramid_raster_image_out_.png"; // Save resultant image image.Save(MyDir, options); } //ExEnd:ConvertDrawingToRasterImage Console.WriteLine("\nCAD drawing converted successfully to raster image format.\nFile saved at " + MyDir); }
public static void Run() { //ExStart:DWGToCompliancePDF // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); string sourceFilePath = MyDir + "Bottom_plate.dwg"; Aspose.CAD.Image cadImage = Aspose.CAD.Image.Load(sourceFilePath); // Create an instance of CadRasterizationOptions and set its various properties Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White; rasterizationOptions.PageWidth = 1600; rasterizationOptions.PageHeight = 1600; // Create an instance of PdfOptions PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions { VectorRasterizationOptions = rasterizationOptions }; pdfOptions.CorePdfOptions = new PdfDocumentOptions(); pdfOptions.CorePdfOptions.Compliance = PdfCompliance.PdfA1a; cadImage.Save(MyDir + "PDFA1_A.pdf", pdfOptions); pdfOptions.CorePdfOptions.Compliance = PdfCompliance.PdfA1b; cadImage.Save(MyDir + "PDFA1_B.pdf", pdfOptions); //ExEnd:DWGToCompliancePDF Console.WriteLine("\nThe DWG file exported successfully to PDF.\nFile saved at " + MyDir); }
public static void Run() { //ExStart:ExportToPDF // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); string sourceFilePath = MyDir + "Bottom_plate.dwg"; using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) { // Create an instance of CadRasterizationOptions and set its various properties Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White; rasterizationOptions.PageWidth = 1600; rasterizationOptions.PageHeight = 1600; // Create an instance of PdfOptions Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); // Set the VectorRasterizationOptions property pdfOptions.VectorRasterizationOptions = rasterizationOptions; MyDir = MyDir + "Bottom_plate_out.pdf"; // Export the DWG to PDF image.Save(MyDir, pdfOptions); } //ExEnd:ExportToPDF Console.WriteLine("\nThe DWG file exported successfully to PDF.\nFile saved at " + MyDir); }
///<Summary> /// ConvertCadToPdf method to convert cad to pdf ///</Summary> public Response ConvertCadToPdf(string fileName, string folderName, string outputType) { return(ProcessTask(fileName, folderName, ".pdf", false, false, delegate(string inFilePath, string outPath, string zipOutFolder) { using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(inFilePath)) { Aspose.CAD.ImageOptions.PdfOptions pdfSaveOptions = new Aspose.CAD.ImageOptions.PdfOptions(); if (outputType == "pdfa_1b") { pdfSaveOptions.CorePdfOptions.Compliance = CAD.ImageOptions.PdfCompliance.PdfA1b; } else if (outputType == "pdfa_1a") { pdfSaveOptions.CorePdfOptions.Compliance = CAD.ImageOptions.PdfCompliance.PdfA1a; } else if (outputType == "pdf_15") { pdfSaveOptions.CorePdfOptions.Compliance = CAD.ImageOptions.PdfCompliance.Pdf15; } using (Stream stream = new FileStream(outPath, FileMode.CreateNew)) { image.Save(stream, pdfSaveOptions); } } })); }
void Test02() { var OFD = new OpenFileDialog(); if (OFD.ShowDialog() == DialogResult.OK) { var path = OFD.FileName; using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(path)) { var opt = new CadRasterizationOptions(); //opt.PageWidth = 1600; //opt.PageHeight = 1600; opt.AutomaticLayoutsScaling = true; opt.NoScaling = true; ImageOptionsBase pdfOpt = new PdfOptions(); pdfOpt.VectorRasterizationOptions = opt; image.Save(path + "_TEST.pdf", pdfOpt); } } }
public static void Run() { //ExStart:ExportDXFSpecificLayoutToPDF // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DXFDrawings(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) { // Create an instance of CadRasterizationOptions and set its various properties Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); rasterizationOptions.PageWidth = 1600; rasterizationOptions.PageHeight = 1600; // Specify desired layout name rasterizationOptions.Layouts = new string[] { "Model" }; // Create an instance of PdfOptions Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); // Set the VectorRasterizationOptions property pdfOptions.VectorRasterizationOptions = rasterizationOptions; MyDir = MyDir + "conic_pyramid_layout_out.pdf"; // Export the DXF to PDF image.Save(MyDir, pdfOptions); } //ExEnd:ExportDXFSpecificLayoutToPDF Console.WriteLine("\nThe DXF file with specific layout exported successfully to PDF.\nFile saved at " + MyDir); }
public static void Run() { //ExStart:ConvertLayoutsToRasterImage // The path to the documents directory. string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) { // Create an instance of CadRasterizationOptions Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); // Set page width & height rasterizationOptions.PageWidth = 1200; rasterizationOptions.PageHeight = 1200; // Specify a list of layout names rasterizationOptions.Layouts = new string[] { "Model", "Layout1" }; // Create an instance of TiffOptions for the resultant image ImageOptionsBase options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); // Set rasterization options options.VectorRasterizationOptions = rasterizationOptions; MyDir = MyDir + "conic_pyramid_layoutstorasterimage_out_.tiff"; // Save resultant image image.Save(MyDir, options); } //ExEnd:ConvertLayoutsToRasterImage Console.WriteLine("\nCAD layouts converted successfully to raster image format.\nFile saved at " + MyDir); }
public static void Run() { //ExStart:SettingAutoLayoutScaling // The path to the documents directory. string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) { // Create an instance of CadRasterizationOptions and set its various properties Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); rasterizationOptions.PageWidth = 1600; rasterizationOptions.PageHeight = 1600; // Set Auto Layout Scaling rasterizationOptions.AutomaticLayoutsScaling = true; // Create an instance of PdfOptions Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); // Set the VectorRasterizationOptions property pdfOptions.VectorRasterizationOptions = rasterizationOptions; MyDir = MyDir + "result_out.pdf"; //Export the CAD to PDF image.Save(MyDir, pdfOptions); } //ExEnd:SettingAutoLayoutScaling Console.WriteLine("\nAuto layout scaling setup successfully.\nFile saved at " + MyDir); }
///<Summary> /// ConvertCadToTiff method to convert cad to tiff ///</Summary> public Response ConvertCadToTiff(string fileName, string folderName) { return(ProcessTask(fileName, folderName, ".tiff", false, false, delegate(string inFilePath, string outPath, string zipOutFolder) { using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(inFilePath)) { Aspose.CAD.ImageOptions.TiffOptions tiffSaveOptions = new Aspose.CAD.ImageOptions.TiffOptions(CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.TiffJpegRgb); image.Save(outPath, tiffSaveOptions); } })); }
public static void Run() { //ExStart:RenderDWGDocument // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); string sourceFilePath = MyDir + "Bottom_plate.dwg"; using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) { CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.Layouts = new string[] { "Model" }; rasterizationOptions.NoScaling = true; // note: preserving some empty borders around part of image is the responsibility of customer // top left point of region to draw Point topLeft = new Point(6156, 7053); double width = 3108; double height = 2489; CadVportTableObject newView = new CadVportTableObject(); // note: exactly such table name is required for active view newView.TableName = "*Active"; newView.CenterPoint.X = topLeft.X + width / 2f; newView.CenterPoint.Y = topLeft.Y - height / 2f; newView.ViewHeight.Value = height; newView.ViewAspectRatio.Value = width / height; // search for active viewport and replace it for (int i = 0; i < cadImage.ViewPorts.Count; i++) { CadVportTableObject currentView = (CadVportTableObject)(cadImage.ViewPorts[i]); if ((currentView.TableName == null && cadImage.ViewPorts.Count == 1) || string.Equals(currentView.TableName.ToLowerInvariant(), "*active")) { cadImage.ViewPorts[i] = newView; break; } } image.Save(MyDir, pdfOptions); } //ExEnd:RenderDWGDocument Console.WriteLine("\nThe DWG file exported successfully to PDF.\nFile saved at " + MyDir); }
public static void Run() { //ExStart:ListLayouts // The path to the documents directory. string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) { Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)image; Aspose.CAD.FileFormats.Cad.CadLayoutDictionary layouts = cadImage.Layouts; foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadLayout layout in layouts.Values) { Console.WriteLine("Layout " + layout.LayoutName); } } //ExEnd:ListLayouts }
public static void Run() { //ExStart:CADLayoutsToPDF // The path to the documents directory. string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; // Create an instance of CadImage class and load the file. using (Aspose.CAD.Image cadImage = (Aspose.CAD.Image)Image.Load(sourceFilePath)) { // Create an instance of CadRasterizationOptions class CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.PageWidth = 1600; rasterizationOptions.PageHeight = 1600; // Set the Entities type property to Entities3D. rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; rasterizationOptions.AutomaticLayoutsScaling = true; rasterizationOptions.NoScaling = false; rasterizationOptions.ContentAsBitmap = true; // Set Layouts rasterizationOptions.Layouts = new string[] { "Model" }; // Create an instance of PDF options class PdfOptions pdfOptions = new PdfOptions(); pdfOptions.VectorRasterizationOptions = rasterizationOptions; MyDir = MyDir + "CADLayoutsToPDF_out.pdf"; // Set Graphics options rasterizationOptions.GraphicsOptions.SmoothingMode = SmoothingMode.HighQuality; rasterizationOptions.GraphicsOptions.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; rasterizationOptions.GraphicsOptions.InterpolationMode = InterpolationMode.HighQualityBicubic; //Export to PDF by calling the Save method cadImage.Save(MyDir, pdfOptions); } //ExEnd:CADLayoutsToPDF Console.WriteLine("\n3D images exported successfully to PDF.\nFile saved at " + MyDir); }
public static void Run() { //ExStart:Export3DImagestoPDF // The path to the documents directory. string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; using (Aspose.CAD.Image cadImage = Aspose.CAD.Image.Load(sourceFilePath)) { Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); rasterizationOptions.PageWidth = 500; rasterizationOptions.PageHeight = 500; rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; rasterizationOptions.Layouts = new string[] { "Model" }; PdfOptions pdfOptions = new PdfOptions(); pdfOptions.VectorRasterizationOptions = rasterizationOptions; MyDir = MyDir + "Export3DImagestoPDF_out.pdf"; cadImage.Save(MyDir, pdfOptions); } //ExEnd:Export3DImagestoPDF Console.WriteLine("\n3D images exported successfully to PDF.\nFile saved at " + MyDir); }
void Test01() { var OFD = new OpenFileDialog(); if (OFD.ShowDialog() == DialogResult.OK) { var path = OFD.FileName; using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(path)) { CadRasterizationOptions opt = new CadRasterizationOptions(); opt.PageWidth = 1200; opt.PageHeight = 1200; ImageOptionsBase opts = new PdfOptions(); opts.VectorRasterizationOptions = opt; image.Save(path + "_TEST.pdf"); } } }
///<Summary> /// ConvertCadToImages method to convert cad to images ///</Summary> public Response ConvertCadToImages(string fileName, string folderName, string outputType) { if (outputType.Equals("bmp") || outputType.Equals("jpg") || outputType.Equals("png") || outputType.Equals("gif") || outputType.Equals("svg")) { ImageOptionsBase imageOptionsBase = new BmpOptions(); if (outputType.Equals("jpg")) { imageOptionsBase = new JpegOptions(); } else if (outputType.Equals("png")) { imageOptionsBase = new PngOptions(); } else if (outputType.Equals("gif")) { imageOptionsBase = new GifOptions(); } else if (outputType.Equals("svg")) { imageOptionsBase = new SvgOptions(); } return(ProcessTask(fileName, folderName, "." + outputType, false, false, delegate(string inFilePath, string outPath, string zipOutFolder) { using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(inFilePath)) { image.Save(outPath, imageOptionsBase); } })); } return(new Response { FileName = null, Status = "Output type not found", StatusCode = 500 }); }
public static void Run() { //ExStart:EnableTrackingForCADRendering // The path to the documents directory. string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) { MemoryStream stream = new MemoryStream(); Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); // Create an instance of CadRasterizationOptions and set its various properties Aspose.CAD.ImageOptions.CadRasterizationOptions cadRasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; cadRasterizationOptions.PageWidth = 800; cadRasterizationOptions.PageHeight = 600; image.Save(stream, pdfOptions); } //ExEnd:EnableTrackingForCADRendering Console.WriteLine("\nTracking enabled successfully for CAD rendering process."); }
public static void Run() { //ExStart:SettingCanvasSizeAndMode // The path to the documents directory. string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) { // Create an instance of CadRasterizationOptions and set its various properties Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); rasterizationOptions.PageWidth = 1600; rasterizationOptions.PageHeight = 1600; rasterizationOptions.AutomaticLayoutsScaling = true; rasterizationOptions.NoScaling = false; // Create an instance of PdfOptions Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); // Set the VectorRasterizationOptions property pdfOptions.VectorRasterizationOptions = rasterizationOptions; //Export CAD to PDF image.Save(MyDir + "result_out.pdf", pdfOptions); // Create an instance of TiffOptions Aspose.CAD.ImageOptions.TiffOptions tiffOptions = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); // Set the VectorRasterizationOptions property tiffOptions.VectorRasterizationOptions = rasterizationOptions; //Export CAD to TIFF image.Save(MyDir + "result_out.tiff", tiffOptions); } //ExEnd:SettingCanvasSizeAndMode Console.WriteLine("\nCanvas size and mode setup successfully."); }
public static void Run() { //ExStart:SettingBackgroundAndDrawingColors // The path to the documents directory. string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(sourceFilePath)) { // Create an instance of CadRasterizationOptions and set its various properties Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); rasterizationOptions.PageWidth = 1600; rasterizationOptions.PageHeight = 1600; rasterizationOptions.BackgroundColor = Aspose.CAD.Color.Beige; rasterizationOptions.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseDrawColor; rasterizationOptions.DrawColor = Aspose.CAD.Color.Blue; // Create an instance of PdfOptions Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); // Set the VectorRasterizationOptions property pdfOptions.VectorRasterizationOptions = rasterizationOptions; //Export CAD to PDF image.Save(MyDir + "result_out.pdf", pdfOptions); // Create an instance of TiffOptions Aspose.CAD.ImageOptions.TiffOptions tiffOptions = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); // Set the VectorRasterizationOptions property tiffOptions.VectorRasterizationOptions = rasterizationOptions; //Export CAD to TIFF image.Save(MyDir + "result_out.tiff", tiffOptions); } //ExEnd:SettingBackgroundAndDrawingColors Console.WriteLine("\nBackground and drawing colors setup successfully."); }