AutoCAD处理控件Aspose.CAD转换功能演示:将CAD工程图转换为PDF和光栅图像格式

Aspose.CAD for .NET是一个独立的AutoCAD处理API。它提供将DWG,DWF和DXF文件转换为高质量PDF和光栅图像的功能。开发人员可以从AutoCAD文件中选择和转换特定的布局和图层,并轻松跟踪整个文件转换过程。

近期Aspose.CAD for .Net更新至最新版v20.1,新增了三个非常实用的新功能——支持OBJ格式、支持将DWG转换为DWF、能够操纵AutoCAD工程图中的超链接,接下来,我们通过示例来了解新增功能!

>>欢迎下载Aspose.CAD for .NET v20.1体验

将CAD工程图转换为栅格图像格式

Aspose.CAD for .NET能够将CAD绘图格式(例如DXF和DWG)转换为受支持的光栅图像格式,例如PNG,BMP,TIFF,JPEG和GIF。Aspose.CAD for .NET API已公开了有效且易于使用的方法来实现此目标。

可以使用下面介绍的简单步骤将任何受支持的CAD工程图格式转换为栅格图像格式。

  1. 将CAD文件加载到Image的实例中
  2. 创建一个CadRasterizationOptions实例,并设置其必填属性,例如PageWidth 和PageHeight
  3. 创建ImageOptionsBase 的实例并将其VectorRasterizationOptions 属性设置为在上一步中创建的CadRasterizationOptions实例
  4. 呼叫Image.Save通过将文件路径(或的MemoryStream的对象)以及实例ImageOptionsBase在先前步骤中创建的
// 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);        }

将CAD布局转换为栅格图像格式

Aspose.CAD for .NET API能够将受支持格式(如DXF和DWG)的 CAD布局转换为光栅图像(如PNG,BMP,TIFF,JPEG和GIF)。该API还提供了将CAD图形的特定布局呈现到不同PSD层的支持。

Aspose.CAD for .NET API已公开了有效且易于使用的方法,用于指定所需CAD布局的列表并将其呈现为光栅图像格式。您可以通过以下5个简单的步骤来实现相同的目标。

  1. 使用工厂方法Load将CAD文件加载到Image实例中。
  2. 创建一个CadRasterizationOptions实例,并设置其必填属性,例如PageWidth和PageHeight。
  3. 使用CadRasterizationOptions.Layouts属性指定所需的布局名称。
  4. 创建ImageOptionsBase的实例并将其VectorRasterizationOptions属性设置为在上一步中创建的CadRasterizationOptions实例。
  5. 呼叫Image.Save通过将文件路径(或的MemoryStream的对象)以及实例ImageOptionsBase在先前步骤中创建的。

// 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);        }

还想要更多吗可以点击阅读【2019 · Aspose最新资源整合】查找需要的教程资源。如果您有任何疑问或需求,请随时联系客服,我们很高兴为您提供查询和咨询
标签:

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2020年1月23日
下一篇 2020年1月23日

相关推荐

发表回复

登录后才能评论