public static void Run() { //ExStart:PenSupportInExport string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; CadImage cadImage = (CadImage)Image.Load(sourceFilePath); CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); PdfOptions pdfOptions = new PdfOptions(); // Here user can change default start cap and end cap of pens when exporting CadImage object to // image. It can be using for all image formats: pdf, png, bmp, gif, jpeg2000, jpeg, psd, tiff, wmf. // If user doesn't use PenOptions, system will use its own default pens (different in defferent places). rasterizationOptions.PenOptions = new PenOptions { StartCap = LineCap.Flat, EndCap = LineCap.Flat }; pdfOptions.VectorRasterizationOptions = rasterizationOptions; cadImage.Save(GetFileFromDesktop(MyDir + "9LHATT-A56_generated.pdf"), pdfOptions); //ExEnd:PenSupportInExport }
public static void Run() { //ExStart:ExportDXFToWMF // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DXFDrawings(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; using (var image = Image.Load("NRB-GRID-BLOCK-MD-PROVALVDK-241000-162000-45400.dgn")) { var vectorOptions = new CadRasterizationOptions(); vectorOptions.AutomaticLayoutsScaling = true; vectorOptions.BackgroundColor = Color.Black; vectorOptions.PageWidth = 500; vectorOptions.PageHeight = 500; WmfOptions wmfOptions = new WmfOptions() { VectorRasterizationOptions = vectorOptions }; image.Save("NRB-GRID-BLOCK-MD-PROVALVDK-241000-162000-45400.dgn.wmf", wmfOptions); } //ExEnd:ExportDXFToWMF Console.WriteLine("\nThe DXF drawing exported successfully to PDF.\nFile saved at " + MyDir); }
public static void Run() { //ExStart:SupportForHiddenLines // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); string sourceFilePath = MyDir + "Bottom_plate.dwg"; string outPath = MyDir + "Bottom_plate.pdf"; using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) { CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.PageHeight = cadImage.Height; rasterizationOptions.PageWidth = cadImage.Width; rasterizationOptions.Layers = new string[] { "Print", "L1_RegMark", "L2_RegMark" }; PdfOptions pdfOptions = new PdfOptions(); rasterizationOptions.Layouts = new string[] { "Model" }; pdfOptions.VectorRasterizationOptions = rasterizationOptions; cadImage.Save(outPath, pdfOptions); } Console.WriteLine("\nThe DWG file exported successfully to PDF.\nFile saved at " + MyDir); }
public static void Run() { //ExStart:MeshSupport string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + ("meshes.dwg"); string outPath = MyDir + ("meshes.pdf"); using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) { CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.PageWidth = 1600; rasterizationOptions.PageHeight = 1600; rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; rasterizationOptions.Layouts = new string[] { "Model" }; PdfOptions pdfOptions = new PdfOptions { VectorRasterizationOptions = rasterizationOptions }; { cadImage.Save(outPath, pdfOptions); } } //ExEnd:MeshSupport }
public static void Run() { //ExStart:ExportPLTtoPDF // The path to the documents directory. string MyDir = RunExamples.GetDataDir_PLTDrawings(); string sourceFilePath = MyDir + "50states.plt"; using (Image cadImage = Image.Load(sourceFilePath)) { CadRasterizationOptions options = new CadRasterizationOptions { PageHeight = 1600, PageWidth = 1600, DrawType = CadDrawTypeMode.UseObjectColor, BackgroundColor = Color.White }; PdfOptions pdfOptions = new PdfOptions(); pdfOptions.VectorRasterizationOptions = options; cadImage.Save(MyDir + "50states.pdf", pdfOptions); } //ExEnd:ExportPLTtoPDF }
public static void Run() { //ExStart:ExportOLEObjects // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); string[] files = new string[] { "D ZD junior D10m H2m.dwg", "ZD - Senior D6m H2m45.dwg" }; PngOptions pngOptions = new PngOptions { }; CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); pngOptions.VectorRasterizationOptions = rasterizationOptions; rasterizationOptions.Layouts = new string[] { "Layout1" }; foreach (string file in files) { using (CadImage cadImage = (CadImage)Image.Load(MyDir + file)) { cadImage.Save(MyDir + file + "_out.png", pngOptions); } } //ExEnd:ExportOLEObjects }
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:ColorRendering // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); string inputFile = MyDir + "test1.dwg"; string outputFile = MyDir + "test1.png"; using (FileStream fs = new FileStream(inputFile, FileMode.Open)) { using (FileStream output = new FileStream(outputFile, FileMode.Create)) { Image document = Image.Load(fs); PngOptions saveOptions = new PngOptions(); CadRasterizationOptions options = new CadRasterizationOptions(); options.NoScaling = false; //options.CenterDrawing = true; options.PageHeight = document.Height * 10; options.PageWidth = document.Width * 10; options.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor; saveOptions.VectorRasterizationOptions = options; document.Save(output, saveOptions); } } //ExEnd:ColorRendering }
public static void Run() { //ExStart:ExportToBMP // The path to the documents directory. string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string inputFile = MyDir + "18-12-11 9644 - site.dwf"; using (Image image = Image.Load(inputFile)) { BmpOptions bmpOptions = new BmpOptions(); var dwfRasterizationOptions = new CadRasterizationOptions(); bmpOptions.VectorRasterizationOptions = dwfRasterizationOptions; //dwfRasterizationOptions.CenterDrawing = true; dwfRasterizationOptions.PageHeight = 500; dwfRasterizationOptions.PageWidth = 500; // export string outPath = MyDir + "18-12-11 9644 - site.bmp"; image.Save(outPath, bmpOptions); } //ExEnd:ExportToBMP Console.WriteLine("\n3D images exported successfully to BMP.\nFile saved at " + MyDir); }
public static void Run() { //ExStart:ExportDWFToPDF // The path to the documents directory. string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string fileName = MyDir + "18-12-11 9644 - site.dwf"; using (Image image = Image.Load(fileName)) { CadRasterizationOptions dwfRasterizationOptions = new CadRasterizationOptions(); dwfRasterizationOptions.PageHeight = 500; dwfRasterizationOptions.PageWidth = 500; PdfOptions pdfOptions = new PdfOptions(); pdfOptions.VectorRasterizationOptions = dwfRasterizationOptions; // export string outPath = MyDir + "18-12-11 9644 - site.pdf"; image.Save(outPath, pdfOptions); //ExEnd:ExportDWFToPDF Console.WriteLine("\n3D images exported successfully to PDF.\nFile saved at " + MyDir); } }
public static void Run() { //ExStart:SinglePDFWithDifferentLayouts // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); using (CadImage cadImage = (CadImage)Image.Load(MyDir + "City skyway map.dwg")) { CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.PageWidth = 1000; rasterizationOptions.PageHeight = 1000; //custom sizes for several layouts rasterizationOptions.LayoutPageSizes.Add("ANSI C Plot", new SizeF(500, 1000)); rasterizationOptions.LayoutPageSizes.Add("8.5 x 11 Plot", new SizeF(1000, 100)); PdfOptions pdfOptions = new PdfOptions() { VectorRasterizationOptions = rasterizationOptions }; cadImage.Save(MyDir + "singlePDF_out.pdf", pdfOptions); } //ExEnd:SinglePDFWithDifferentLayouts }
public static void Run() { //ExStart:AddTextInDWG string MyDir = RunExamples.GetDataDir_DWGDrawings(); string dwgPathToFile = MyDir + "SimpleEntites.dwg"; using (Image image = Image.Load(dwgPathToFile)) { CadText cadText = new CadText(); cadText.StyleType = "Standard"; cadText.DefaultValue = "Some custom text"; cadText.ColorId = 256; cadText.LayerName = "0"; cadText.FirstAlignment.X = 47.90; cadText.FirstAlignment.Y = 5.56; cadText.TextHeight = 0.8; cadText.ScaleX = 0.0; CadImage cadImage = (CadImage)image; cadImage.BlockEntities["*Model_Space"].AddEntity(cadText); PdfOptions pdfOptions = new PdfOptions(); CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; cadRasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor; //cadRasterizationOptions.CenterDrawing = true; cadRasterizationOptions.PageHeight = 1600; cadRasterizationOptions.PageWidth = 1600; cadRasterizationOptions.Layouts = new string[] { "Model" }; image.Save(MyDir + "SimpleEntites_generated.pdf", pdfOptions); } //ExEnd:AddTextInDWG }
public static void Run() { //ExStart:1 string SourceDir = RunExamples.GetDataDir_DWGDrawings(); string OutputDir = RunExamples.GetDataDir_Output(); using (Image cadDrawing = Image.Load(SourceDir + "Drawing11.dwg")) { var rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.PageWidth = cadDrawing.Size.Width; rasterizationOptions.PageHeight = cadDrawing.Size.Height; using (var its = new InterruptionTokenSource()) { PdfOptions CADf = new PdfOptions(); CADf.VectorRasterizationOptions = rasterizationOptions; CADf.InterruptionToken = its.Token; var exportTask = Task.Factory.StartNew(() => { cadDrawing.Save(OutputDir + "PutTimeoutOnSave_out.pdf", CADf); }); Thread.Sleep(10000); its.Interrupt(); exportTask.Wait(); } } //ExEnd:1 Console.WriteLine("PutTimeoutOnSave executed successfully"); }
public static void Run() { //ExStart:LargeDWGToPDF // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); string filePathDWG = MyDir + "TestBigFile.dwg"; string filePathFinish = MyDir + "TestBigFile.dwg.pdf"; Stopwatch stopWatch = new Stopwatch(); try { stopWatch.Start(); using (CadImage cadImage = (CadImage)Image.Load(filePathDWG)) { stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. TimeSpan ts = stopWatch.Elapsed; // Format and display the TimeSpan value. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine("RunTime for loading " + elapsedTime); CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.PageWidth = 1600; rasterizationOptions.PageHeight = 1600; PdfOptions pdfOptions = new PdfOptions(); pdfOptions.VectorRasterizationOptions = rasterizationOptions; stopWatch = new Stopwatch(); stopWatch.Start(); cadImage.Save(filePathFinish, pdfOptions); stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. ts = stopWatch.Elapsed; // Format and display the TimeSpan value. elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine("RunTime for converting " + elapsedTime); } } catch (Exception ex) { Console.WriteLine(ex.Message); } //ExEnd:LargeDWGToPDF }
public static void Run() { //ExStart:ExportDWGToPDFOrRaster // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); string sourceFilePath = MyDir + "Bottom_plate.dwg"; string outPath = MyDir + "Bottom_plate.pdf"; using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) { // export to pdf CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.Layouts = new string[] { "Model" }; bool currentUnitIsMetric = false; double currentUnitCoefficient = 1.0; DefineUnitSystem(cadImage.UnitType, out currentUnitIsMetric, out currentUnitCoefficient); if (currentUnitIsMetric) { double metersCoeff = 1 / 1000.0; double scaleFactor = metersCoeff / currentUnitCoefficient; rasterizationOptions.PageWidth = (float)(210 * scaleFactor); rasterizationOptions.PageHeight = (float)(297 * scaleFactor); rasterizationOptions.UnitType = UnitType.Millimeter; } else { rasterizationOptions.PageWidth = (float)(8.27f / currentUnitCoefficient); rasterizationOptions.PageHeight = (float)(11.69f / currentUnitCoefficient); rasterizationOptions.UnitType = UnitType.Inch; } rasterizationOptions.AutomaticLayoutsScaling = true; PdfOptions pdfOptions = new PdfOptions { VectorRasterizationOptions = rasterizationOptions }; cadImage.Save(outPath, pdfOptions); // export to raster //A4 size at 300 DPI - 2480 x 3508 rasterizationOptions.PageHeight = 3508; rasterizationOptions.PageWidth = 2480; PngOptions pngOptions = new PngOptions { VectorRasterizationOptions = rasterizationOptions }; cadImage.Save(outPath.Replace("pdf", "png"), pngOptions); } }
public static void Run() { //ExStart:1 // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); string sourceFilePath = MyDir + "visualization_-_conference_room.dwg"; using (CadImage cadImage = (CadImage)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(500, 1000); double width = 3108; double height = 2489; CadVportTableObject newView = new CadVportTableObject(); newView.Name = new CadStringParameter(); newView.Name.Init("*Active"); newView.CenterPoint.X = topLeft.X + width / 2f; newView.CenterPoint.Y = topLeft.Y - height / 2f; newView.ViewHeight.Value = height; newView.ViewAspectRatio.Value = width / height; for (int i = 0; i < cadImage.ViewPorts.Count; i++) { CadVportTableObject currentView = (CadVportTableObject)(cadImage.ViewPorts[i]); if (cadImage.ViewPorts.Count == 1 || string.Equals(currentView.Name.Value.ToLowerInvariant(), "*active")) { cadImage.ViewPorts[i] = newView; break; } } // Create an instance of PdfOptions Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions(); // Set the VectorRasterizationOptions property pdfOptions.VectorRasterizationOptions = rasterizationOptions; MyDir = MyDir + "ConvertDWGToPDFBySupplyingCoordinates_out.pdf"; //Export the DWG to PDF cadImage.Save(MyDir, pdfOptions); } //ExEnd:1 Console.WriteLine("\nThe DWG file exported successfully to PDF.\nFile saved at " + MyDir); }
//ExStart:PLTSupport public static void Run() { string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "themepark.plt"; Image image = Image.Load((sourceFilePath)); ImageOptionsBase imageOptions = new JpegOptions(); CadRasterizationOptions options = new CadRasterizationOptions { PageHeight = 500, PageWidth = 1000, }; imageOptions.VectorRasterizationOptions = options; image.Save((MyDir + "themepark.jpg"), imageOptions); }
public static void Run() { //ExStart:GetSizeOfDwfLayout // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWFDrawings(); string sourceFilePath = MyDir + "blocks_and_tables.dwf"; string extension = Path.GetExtension(sourceFilePath); using (DwfImage image = (DwfImage)Aspose.CAD.Image.Load(sourceFilePath)) { foreach (var page in image.Pages) { var layout = page.Name; System.Console.WriteLine("Layout= " + layout); using (FileStream fs = new FileStream(MyDir + "layout_" + layout + ".jpg", FileMode.Create)) { JpegOptions jpegOptions = new JpegOptions(); CadRasterizationOptions options = new CadRasterizationOptions(); options.Layouts = new string[] { layout }; double sizeExtX = page.MaxPoint.X - page.MinPoint.X; double sizeExtY = page.MaxPoint.Y - page.MinPoint.Y; if (page.UnitType == UnitType.Inch) { options.PageHeight = CommonHelper.INtoPixels(sizeExtY, CommonHelper.DPI); options.PageWidth = CommonHelper.INtoPixels(sizeExtX, CommonHelper.DPI); } else if (page.UnitType == UnitType.Millimeter) { options.PageHeight = CommonHelper.MMtoPixels(sizeExtY, CommonHelper.DPI); options.PageWidth = CommonHelper.MMtoPixels(sizeExtX, CommonHelper.DPI); } else { options.PageHeight = (float)sizeExtY; options.PageWidth = (float)sizeExtX; } //options.CenterDrawing = true; jpegOptions.VectorRasterizationOptions = options; image.Save(fs, jpegOptions); } } } //ExEnd:GetSizeOfDwfLayout }
public static void Run() { //ExStart:RenderDWGDocument // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DWGDrawings(); string sourceFilePath = MyDir + "Bottom_plate.dwg"; using (CadImage cadImage = (CadImage)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.Name.Value = "*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.Name.Value == null && cadImage.ViewPorts.Count == 1) || string.Equals(currentView.Name.Value.ToLowerInvariant(), "*active")) { cadImage.ViewPorts[i] = newView; break; } } PdfOptions pdfOptions = new PdfOptions(); rasterizationOptions.Layouts = new string[] { "Model" }; pdfOptions.VectorRasterizationOptions = rasterizationOptions; cadImage.Save(MyDir, pdfOptions); } //ExEnd:RenderDWGDocument Console.WriteLine("\nThe DWG file exported successfully to PDF.\nFile saved at " + MyDir); }
public static void Run() { string MyDir = RunExamples.GetDataDir_DWGDrawings(); //ExStart:ImportImageToDWG string dwgPathToFile = MyDir + "Drawing11.dwg"; CadImage cadImage1 = (CadImage)Image.Load(dwgPathToFile); // using (Image image = ImageLoader.Load(dwgPathToFile)) { CadRasterImageDef cadRasterImageDef = new CadRasterImageDef(); cadRasterImageDef.ObjectHandle = "A3B4"; cadRasterImageDef.FileName = "road-sign-custom.png"; CadRasterImage cadRasterImage = new CadRasterImage(); cadRasterImage.ImageDefReference = "A3B4"; cadRasterImage.InsertionPoint.X = 26.77; cadRasterImage.InsertionPoint.Y = 22.35; cadRasterImage.DisplayFlags = 7; cadRasterImage.ImageSizeU = 640; cadRasterImage.ImageSizeV = 562; cadRasterImage.UVector.X = 0.0061565450840500831; cadRasterImage.UVector.Y = 0; cadRasterImage.VVector.X = 0; cadRasterImage.VVector.Y = 0.0061565450840500822; cadRasterImage.ClippingState = 0; cadRasterImage.ClipBoundaryVertexList.Add(new Cad2DPoint(-0.5, 0.5)); cadRasterImage.ClipBoundaryVertexList.Add(new Cad2DPoint(639.5, 561.5)); CadImage cadImage = (CadImage)cadImage1; cadImage.BlockEntities["*Model_Space"].AddEntity(cadRasterImage); List <CadBaseObject> list = new List <CadBaseObject>(cadImage.Objects); list.Add(cadRasterImageDef); cadImage.Objects = list.ToArray(); PdfOptions pdfOptions = new PdfOptions(); CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; cadRasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor; cadRasterizationOptions.CenterDrawing = true; cadRasterizationOptions.PageHeight = 1600; cadRasterizationOptions.PageWidth = 1600; cadRasterizationOptions.Layouts = new string[] { "Model" }; cadImage1.Save(MyDir + "export2.pdf", pdfOptions); } //ExEnd:ImportImageToDWG }
public static void Run() { string MyDir = RunExamples.GetDataDir_DWGDrawings(); //ExStart:ImportImageToDWG string dwgPathToFile = MyDir + "Drawing11.dwg"; CadImage cadImage1 = (CadImage)Image.Load(dwgPathToFile); CadRasterImageDef cadRasterImageDef = new CadRasterImageDef("road-sign-custom.png", 640, 562); cadRasterImageDef.ObjectHandle = "A3B4"; Cad3DPoint insertionPoint = new Cad3DPoint(26.77, 22.35); Cad3DPoint uVector = new Cad3DPoint(0.0061565450840500831, 0); Cad3DPoint vVector = new Cad3DPoint(0, 0.0061565450840500822); CadRasterImage cadRasterImage = new CadRasterImage(cadRasterImageDef, insertionPoint, uVector, vVector); cadRasterImage.ImageDefReference = "A3B4"; cadRasterImage.DisplayFlags = 7; cadRasterImage.ClippingState = 0; cadRasterImage.ClipBoundaryVertexList.Add(new Cad2DPoint(-0.5, 0.5)); cadRasterImage.ClipBoundaryVertexList.Add(new Cad2DPoint(639.5, 561.5)); CadImage cadImage = (CadImage)cadImage1; cadImage.BlockEntities["*Model_Space"].AddEntity(cadRasterImage); List <CadBaseObject> list = new List <CadBaseObject>(cadImage.Objects); list.Add(cadRasterImageDef); cadImage.Objects = list.ToArray(); PdfOptions pdfOptions = new PdfOptions(); CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; cadRasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor; cadRasterizationOptions.PageHeight = 1600; cadRasterizationOptions.PageWidth = 1600; cadRasterizationOptions.Layouts = new string[] { "Model" }; cadImage1.Save(MyDir + "export2.pdf", pdfOptions); //ExEnd:ImportImageToDWG }
public static void Run() { //ExStart:EnableTracking // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DXFDrawings(); using (Image image = Image.Load(MyDir + "conic_pyramid.dxf")) { using (FileStream stream = new FileStream(MyDir + "output_conic_pyramid.pdf", FileMode.Create)) { PdfOptions pdfOptions = new PdfOptions(); CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions(); pdfOptions.VectorRasterizationOptions = cadRasterizationOptions; cadRasterizationOptions.PageWidth = 800; cadRasterizationOptions.PageHeight = 600; int idxError = 1; cadRasterizationOptions.RenderResult += new CadRasterizationOptions.CadRenderHandler( delegate(CadRenderResult result) { Console.WriteLine("Tracking results of exporting"); if (result.IsRenderComplete) { return; } Console.WriteLine("Have some problems:"); foreach (RenderResult rr in result.Failures) { Console.WriteLine(string.Format("{0}. {1}, {2}", idxError++, rr.RenderCode.ToString(), rr.Message)); } }); Console.WriteLine("Exporting to pdf format"); image.Save(stream, pdfOptions); } } //ExEnd:EnableTracking }
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); }
static void Main() { // The path to the documents directory. string dataDir = Aspose.Imaging.Examples.Utils.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); using (CadImage cadImage = (CadImage)Image.Load(dataDir + "conic_pyramid.dxf")) { CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.PageWidth = 500; rasterizationOptions.PageHeight = 500; rasterizationOptions.TypeOfEntities = TypeOfEntities.Entities3D; //rasterizationOptions.ScaleMethod = ScaleType.GrowToFit; rasterizationOptions.Layouts = new string[] { "Model" }; PdfOptions pdfOptions = new PdfOptions(); pdfOptions.VectorRasterizationOptions = rasterizationOptions; cadImage.Save(dataDir + "output.pdf", pdfOptions); } }
public static void ExportToPNG() { // ExStart: ExportingSTLtoPNG string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "galeon.stl"; using (var cadImage = (CadImage)Image.Load(sourceFilePath)) { var rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.CenterDrawing = true; rasterizationOptions.PageWidth = 100; rasterizationOptions.PageHeight = 100; PngOptions pngOptions = new PngOptions(); pngOptions.VectorRasterizationOptions = rasterizationOptions; string outPath = sourceFilePath + ".png"; cadImage.Save(outPath, pngOptions); } }
public static void Run() { //ExStart:ExportPLTtoImage // The path to the documents directory. string MyDir = RunExamples.GetDataDir_PLTDrawings(); string sourceFilePath = MyDir + "50states.plt"; using (Image cadImage = Image.Load(sourceFilePath)) { ImageOptionsBase imageOptions = new JpegOptions(); CadRasterizationOptions options = new CadRasterizationOptions { PageHeight = 500, PageWidth = 1000, }; imageOptions.VectorRasterizationOptions = options; cadImage.Save(MyDir + "50states.jpg", imageOptions); } //ExEnd:ExportPLTtoImage }
public static void Run() { //ExStart:ExportEmbeddedDGN // The path to the documents directory. string MyDir = RunExamples.GetDataDir_DXFDrawings(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; using (CadImage cadImage = (CadImage)Image.Load(fileName)) { CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.Layouts = new[] { "Model" }; PdfOptions pdfOptions = new PdfOptions(); pdfOptions.VectorRasterizationOptions = rasterizationOptions; cadImage.Save(outDir + fileName + ".pdf", pdfOptions); } //ExEnd:ExportEmbeddedDGN Console.WriteLine("\nThe DXF drawing exported successfully to PDF.\nFile saved at " + MyDir); }
public static void Run() { //ExStart:1 string SourceDir = RunExamples.GetDataDir_DWFXDrawings(); string OutputDir = RunExamples.GetDataDir_Output(); using (Image cadDrawing = Image.Load(SourceDir + "Tyrannosaurus.dwfx")) { var rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.PageWidth = cadDrawing.Size.Width; rasterizationOptions.PageHeight = cadDrawing.Size.Height; PdfOptions CADf = new PdfOptions(); CADf.VectorRasterizationOptions = rasterizationOptions; cadDrawing.Save(OutputDir + "OpenDwfxFile_out.pdf", CADf); } //ExEnd:1 Console.WriteLine("OpenDwfxFile executed successfully"); }
public static void Run() { //ExStart:ACADProxyEntities string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "conic_pyramid.dxf"; using (CadImage cadImage = (CadImage)Image.Load(sourceFilePath)) { CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); rasterizationOptions.UnitType = UnitType.Inch; rasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor; rasterizationOptions.BackgroundColor = Color.Black; rasterizationOptions.Layouts = new string[] { "Model" }; PdfOptions pdfOptions = new PdfOptions { VectorRasterizationOptions = rasterizationOptions }; cadImage.Save(MyDir + "output.pdf", pdfOptions); } //ExEnd:ACADProxyEntities }
public static void ExportToPNG() { //ExStart:ExportingIFCtoPNG //Setfile name path as other examples string MyDir = RunExamples.GetDataDir_ConvertingCAD(); string sourceFilePath = MyDir + "example.ifc"; using (IfcImage cadImage = (IfcImage)Image.Load(sourceFilePath)) { CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); // rasterizationOptions.CenterDrawing = true; rasterizationOptions.PageWidth = 100; rasterizationOptions.PageHeight = 100; PngOptions pngOptions = new PngOptions(); pngOptions.VectorRasterizationOptions = rasterizationOptions; //Set output path as well string outPath = sourceFilePath + ".png"; cadImage.Save(outPath, pngOptions); } }