Convert PDF to DXF via C#, .NET Core

Export PDF to DXF within .NET applications without using Adobe® Acrobat Reader or any other third party applications

PDF Conversion via Java

 

Why Convert PDF to DXF format?

Converting PDF files to DXF (Drawing Exchange Format) format using .NET can offer several advantages. Firstly, DXF is a widely supported format in the CAD (Computer-Aided Design) industry, making it compatible with various CAD software applications. By converting PDF to DXF, you can easily extract and preserve vector-based drawing elements, such as lines, curves, and text, which can be further edited and modified in CAD software. This conversion allows for seamless integration of PDF-based designs or drawings into CAD workflows, facilitating collaboration and interoperability between different design tools. Additionally, converting PDF to DXF enables accurate scaling and measurements, ensuring that the transferred drawings maintain their precision and accuracy.

How Aspose.Total can help in PDF to DXF Conversion?

By utilizing the comprehensive Aspose.Total for .NET libraries, developers gain the necessary tools to streamline the PDF to DXF conversion process within their .NET applications. With the help of Aspose.PDF for .NET , the first step involves exporting the PDF file to JPEG format. Following this, Aspose.Imaging for .NET Image Processing API enables the conversion from JPEG to DXF. This two-step approach simplifies and automates the conversion, allowing developers to seamlessly integrate PDF content into CAD workflows. With the power of Aspose.Total for .NET, the conversion from PDF to DXF becomes efficient and optimized, providing developers with the means to automate this process effortlessly within their .NET applications.

How to Convert PDF to DXF via .NET?

  1. Open PDF file using Document class
  2. Initialize JpegDevice class object and render PDF to JPEG by using Process method
  3. Load JPEG file by using Image class
  4. Save the document to DXF format using Save method

PDF to DXF Converter API for .NET

Install from command line as nuget install Aspose.Total or install directly from Package Manager Console of Visual Studio. Alternatively, get the offline MSI installer or DLLs in a ZIP file from downloads .

// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats
// load PDF with an instance of Document
var document = new Document("input.pdf");
// create an object of jpegDevice
var renderer = new JpegDevice();
// convert a particular page and save the image in JPEG format
renderer.Process(document.Pages[1], "output.jpeg");
// load JPEG file
var image = Image.Load("output.jpeg");
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats
// save JPEG to PSD file format
image.Save("output.psd", new PsdOptions());

Convert PDF to DXF in a Single File via C#

Using the API, you can also convert PDF file to DXF to a single image file. In order to convert all pages, you can first render your PDF document to one TIFF file and after that you can export TIFF file to DXF. You can open the input file using Document class and create Resolution, TiffSettings, & TIFF device objects. You can get a single TIFF image using Process method of TiffDevice class. Finally, you can load TIFF file using Image class and save it to DXF format using Save method.

// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats
// Open PDF document
Document pdfDocument = new Document("input.pdf");
// Create Resolution object
Resolution resolution = new Resolution(300);
// Create TiffSettings object
TiffSettings tiffSettings = new TiffSettings
{
Compression = CompressionType.None,
Depth = ColorDepth.Default,
Shape = ShapeType.Landscape,
SkipBlankPages = false
};
// Create TIFF device
TiffDevice tiffDevice = new TiffDevice(resolution, tiffSettings);
// Convert a particular page and save the image to stream
tiffDevice.Process("output.tif");
// load TIFF file
var image = Image.Load("output.tif");
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats
// save TIFF to PSD file format
image.Save("output.psd", new PsdOptions());

Export PDF to DXF with Watermark via C#

Using the API, you can also convert PDF file to DXF with watermark in your DXF document. In order to add a watermark, you can first render your PDF document to JPEG and add a watermark in it. To demonstrate the operation, you can load your converted JPEG image, add transformations using an object of Matrix class and draw a string as the watermark on the image surface using the Graphics class’ DrawString method. After adding the watermark in it, you can save the JPEG as DXF format. Below is a code example that demonstrates how to add a diagonal watermark to your document.

// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats
// load PDF with an instance of Document
var document = new Document("input.pdf");
// create an object of jpegDevice
var renderer = new JpegDevice();
// convert a particular page and save the image in JPEG format
renderer.Process(document.Pages[1], "output.jpeg");
// load an existing JPEG image
Image image = Image.Load("output.jpeg");
// declare a String object with Watermark Text
string theString = "45 Degree Rotated Text";
// create and initialize an instance of Graphics class and Initialize an object of SizeF to store image Size
Graphics graphics = new Graphics(image);
SizeF sz = graphics.Image.Size;
// create an instance of Font, initialize it with Font Face, Size and Style
Font font = new Font("Times New Roman", 20, FontStyle.Bold);
// create an instance of SolidBrush and set its various properties
SolidBrush brush = new SolidBrush();
brush.Color = Color.Red;
brush.Opacity = 0;
// initialize an object of StringFormat class and set its various properties
StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center;
format.FormatFlags = StringFormatFlags.MeasureTrailingSpaces;
// create an object of Matrix class for transformation
Matrix matrix = new Matrix();
// first a translation then a rotation
matrix.Translate(sz.Width / 2, sz.Height / 2);
matrix.Rotate(-45.0f);
// set the Transformation through Matrix
graphics.Transform = matrix;
// draw the string on Image Save output to disk
graphics.DrawString(theString, font, brush, 0, 0, format);
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats
// save JPEG to PSD file format with watermark in it
image.Save("output.psd", new PsdOptions());

Convert & Rotate PDF to DXF via C#

Using the API, you can also rotate the output DXF image as per your needs. The Image.RotateFlip method can be used to rotate the image by 90/180/270-degrees and flip the image horizontally or vertically. You can specify the type of rotation and flip to apply to the image. In order to rotate and flip the image you can load the converted JPEG image using the factory method exposed by Image class and call the Image.RotateFlip method while specifying the appropriate RotateFlipType .

// supports PDF, CGM, EPUB, TeX, PCL, PS, XPS, MD, MHTML, XSLFO, HTML file formats
// load PDF with an instance of Document
var document = new Document("input.pdf");
// create an object of jpegDevice
var renderer = new JpegDevice();
// convert a particular page and save the image in JPEG format
renderer.Process(document.Pages[1], "output.jpeg");
// load JPEG file
var image = Image.Load("output.jpeg");
// rotate the image
image.RotateFlip(RotateFlipType.Rotate270FlipNone);
// supports Dicom, Jpeg2000, Apng, Psd, Dxf, Wmf, Emz, Wmz, Tga, Svgz file formats
// save JPEG to PSD file format
image.Save("output.psd", new PsdOptions());

Transforming PDF File to DXF Programmatically : Use Cases

PDF (Portable Document Format) files are used to store document information, making them ideal for creating static documents and publications. However, when working with detailed drawings and designs, DXF (Drawing Exchange Format) becomes essential for accurate representation and manipulation.

The conversion of PDF files into DXF formats is necessary to unlock the full potential of your design capabilities. This conversion enables you to:

Use Cases:

  • Architectural and Engineering Design: Convert PDF files to create detailed drawings, designs, and schematics that can be easily edited and shared.
  • Product Manufacturing and Prototyping: Use DXF to generate 2D and 3D models from existing designs, facilitating the creation of prototypes, molds, and tooling.
  • CADCAM (Computer-Aided Design/Computer-Aided Manufacturing): Convert PDF files to create precise digital models for CNC machining, fabrication, and assembly.
  • Geospatial Data Conversion: Use DXF to convert PDF files containing geospatial data into a format that can be used with GIS software, enabling detailed mapping and analysis.
  • Automotive and Aerospace Design: Convert PDF files to generate 2D and 3D models from existing designs, facilitating the creation of prototypes, tooling, and manufacturing plans.

Explore PDF Conversion Options with .NET

Convert PDF to CSV (Comma Seperated Values)
Convert PDF to EXCEL (Spreadsheet File Formats)
Convert PDF to APNG (Animated Portable Network Graphics)
Convert PDF to DICOM (Digital Imaging and Communications in Medicine)
Convert PDF to DIF (Data Interchange Format)
Convert PDF to DOCM (Microsoft Word 2007 Marco File)
Convert PDF to DOT (Microsoft Word Template Files)
Convert PDF to DOTM (Microsoft Word 2007+ Template File)
Convert PDF to DOTX (Microsoft Word Template File)
Convert PDF to EMZ (Windows Compressed Enhanced Metafile)
Convert PDF to FLATOPC (Microsoft Word 2003 WordprocessingML)
Convert PDF to FODS (OpenDocument Flat XML Spreadsheet)
Convert PDF to GIF (Graphical Interchange Format)
Convert PDF to IMAGE (Image Files)
Convert PDF to JPEG2000 (J2K Image Format)
Convert PDF to MARKDOWN (Lightweight Markup Language)
Convert PDF to MD (Markdown Language)
Convert PDF to ODP (OpenDocument Presentation Format)
Convert PDF to ODS (OpenDocument Spreadsheet)
Convert PDF to ODT (OpenDocument Text File Format)
Convert PDF to OTP (OpenDocument Standard Format)
Convert PDF to OTT (OpenDocument Template)
Convert PDF to PCL (Printer Command Language)
Convert PDF to POT (Microsoft PowerPoint Template Files)
Convert PDF to POTM (Microsoft PowerPoint Template File)
Convert PDF to POTX (Microsoft PowerPoint Template Presentation)
Convert PDF to Powerpoint (Presentation Files)
Convert PDF to PPS (PowerPoint Slide Show)
Convert PDF to PPSM (Macro-enabled Slide Show)
Convert PDF to PPSX (PowerPoint Slide Show)
Convert PDF to PPT (PowerPoint Presentation)
Convert PDF to PPTM (Macro-enabled Presentation File)
Convert PDF to PS (PostScript File)
Convert PDF to PSD (Photoshop Document)
Convert PDF to RTF (Rich Text Format)
Convert PDF to SVGZ (Compressed Scalable Vector Graphics)
Convert PDF to SWF (Shockwave Flash Movie)
Convert PDF to SXC (StarOffice Calc Spreadsheet)
Convert PDF to TGA (Truevision Graphics Adapter)