Export AutoCAD DXF Drawing to PDF & Set Image Size in .NET Applications

This tutorial explains how .NET developers can export DXF Drawings to PDF using Aspose.Imaging for .NET. Aspose.Imaging includes a feature for reading AutoCAD DXF drawing entities and rendering them as an entire drawing into PDF format. It is possible to customize the conversion process to achieve specific results. <br/> We have introduced a new Cad class in the Aspose.Imaging.FileFormats namespace. The Cad class is a family of AutoCAD drawings and since they all share similar schemes, it was decided to adopt a similar object model for the AutoCAD drawings family. To accomplish DXF to PDF export, a new class, PdfOptions, has been introduced to the Aspose.Imaging.ImageOptions namespace.
//your code here... [C# Code Sample] using Aspose.Imaging.FileFormats.Cad; using Aspose.Imaging.ImageOptions; namespace DxfExamples { /// <summary> /// Represents test examples for DXF -> PDF export /// </summary> public class DxfExamples { /// <summary> /// Default export. /// </summary> public void DefaultExport() { // Name of the file string filename = "Drawing1.dxf"; // Load an image using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(filename)) { // Create options PdfOptions pdfOptions = new PdfOptions(); // Set output file size pdfOptions.PageWidth = 800; pdfOptions.PageHeight = 600; // Export image.Save(filename + ".pdf", pdfOptions); } } } } //[VB.NET Code Sample] Imports Aspose.Imaging.FileFormats.Cad Imports Aspose.Imaging.ImageOptions Namespace DxfExamples ''' <summary> ''' Represents test examples for DXF -> PDF export ''' </summary> Public Class DxfExamples ''' <summary> ''' Default export. ''' </summary> Public Sub DefaultExport() ' Name of the file Dim filename As String = "Drawing1.dxf" ' Load an image Using image As Aspose.Imaging.Image = Aspose.Imaging.Image.Load(filename) ' Create options Dim pdfOptions As New PdfOptions() ' Set output file size pdfOptions.PageWidth = 800 pdfOptions.PageHeight = 600 ' Export image.Save(filename & Convert.ToString(".pdf"), pdfOptions) End Using End Sub End Class End Namespace //Setting the Image Size //[C# Code Sample] //The code sample below shows the auto-scaling option in use. using Aspose.Imaging.FileFormats.Cad; using Aspose.Imaging.ImageOptions; namespace DxfExamples { /// <summary> /// Represents test examples for DXF -> PDF export /// </summary> public class DxfExamples { /// <summary> /// Export with automatical up-scaling. /// </summary> public void ExportAutoUpScale() { // Name of the file string filename = "Drawing2.dxf"; // Load an image using (Aspose.Imaging.Image image = Aspose.Imaging.Image.Load(filename)) { // Create options PdfOptions pdfOptions = new PdfOptions(); // Set output file size pdfOptions.PageWidth = 850; pdfOptions.PageHeight = 600; // Allow upscaling pdfOptions.ScaleMethod = ScaleType.GrowToFit; // Export image.Save(filename + "_UpScale.pdf", pdfOptions); } } } } //[VB.NET Code Sample] Imports Aspose.Imaging.FileFormats.Cad Imports Aspose.Imaging.ImageOptions Namespace DxfExamples ''' <summary> ''' Represents test examples for DXF -> PDF export ''' </summary> Public Class DxfExamples ''' <summary> ''' Export with automatical up-scaling. ''' </summary> Public Sub ExportAutoUpScale() ' Name of the file Dim filename As String = "Drawing2.dxf" ' Load an image Using image As Aspose.Imaging.Image = Aspose.Imaging.Image.Load(filename) ' Create options Dim pdfOptions As New PdfOptions() ' Set output file size pdfOptions.PageWidth = 850 pdfOptions.PageHeight = 600 ' Allow upscaling pdfOptions.ScaleMethod = ScaleType.GrowToFit ' Export image.Save(filename & Convert.ToString("_UpScale.pdf"), pdfOptions) End Using End Sub End Class End Namespace

Url: http://www.aspose.com/.net/imaging-component.aspx

Language: C# | User: Sheraz Khan | Created: Apr 2, 2014 | Tags: Convert DXF Drawings to PDF, Export AutoCAD DXF to PDF, Open DXF drawing file, Setting the Image Size, image auto-scaling option, .NET Imaging Convert DXF Drawings to PDF Export AutoCAD DXF to PDF Open DXF drawing file Setting the Image Size image auto-scaling option .NET Imaging