DXF File Viewer for .NET
View DXF as an image without needing AutoCAD or any other rendering software.
How to View DXF File Using C#
In order to view DXF file, we’ll use
API which is a feature-rich, powerful and easy to use API for C# platform to be used with any Viewer. Open
package manager, search for Aspose.CAD and install. You may also use the following command from the Package Manager Console.
Package Manager Console Command
PM> Install-Package Aspose.CAD
Steps to View DXF via C#
Aspose.CAD makes it easy for the developers to view the DXF file with just few lines of code.
- Load DXF file with Image.Load method
- Set an object of CadRasterizationOptions with page height & width
- Create an instance of TiffOptions class and set its VectorRasterizationOptions property
- Call Image.Save method with object of TiffOptions
- Call Process.Start with path to resultant image to load it in default application
System Requirements
Aspose.CAD for .NET is supported on all major operating systems. Just make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with .NET Framework, .NET Core
- Development environment like Microsoft Visual Studio
- Aspose.CAD for .NET referenced in your project
C# code to view DXF
string output = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".tiff"; | |
// load DXF file in an instance of Image | |
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("template.dxf")) | |
{ | |
// create an instance of CadRasterizationOptions | |
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions(); | |
rasterizationOptions.PageWidth = 1200; | |
rasterizationOptions.PageHeight = 1200; | |
// create an instance of TiffOptions for the resultant image | |
var options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default); | |
// set VectorRasterizationOptions property | |
options.VectorRasterizationOptions = rasterizationOptions; | |
// save DXF as TIFF image | |
image.Save(output, options); | |
} | |
// load resultant TIFF image in default application | |
System.Diagnostics.Process.Start(output); |