Architectural, engineering, and construction drawings are usually produced in both PDF and DWG format. Often, a DWG is used for accurate scaling or inclusion in other programs. So if you only have a PDF, you might need to convert a PDF to a DXF or DWG.
If you want to convert a PDF to a DWG, it is possible to do this in AutoCAD using the pdfimport
command. However, this is a manual process and will be slow when you have many files to convert.
Additionally, DWG is not an open data format. Using non-open data formats in construction is not ethical and should be discouraged in the industry. Instead, a DXF file should be produced. A DXF is functionally equivalent to a DWG for 2D content, and can be opened in other software. It may be larger, as it is in ASCII format, but it can be compressed. If your DWG contains 3D data, it may be worth converting it into an OBJ instead, or ideally, an IFC file if it contains construction data.
To convert a PDF to a DXF, we will first convert from PDF to EPS (Encapsulated PostScript format), and then convert from EPS to DXF. You will require Inkscape, a free and open-source vector editing program similar to Adobe Illustrator. You will also require pstoedit, which is an open-source command line PostScript conversion tool.
We will run the scripts using the command line, as it will be much faster than using a GUI. On Windows, you can run both commands using cygwin.
./inkscape.exe -z --export-eps="file.eps" "file.pdf"
pstoedit -f "dxf" "file.eps" "file.dxf"
Here is a simple shell script that converts all files in a folder called pdf/
into an output folder called dxf/
:
#!/bin/bash
mkdir -p eps
mkdir -p dxf
for FILE in pdf/*.pdf; do
export BASEFILE=`basename "$FILE"`
echo "Processing $FILE"
./inkscape.exe -z --export-eps="eps/$BASEFILE" "pdf/$BASEFILE"
pstoedit -f "dxf" "eps/$BASEFILE" "dxf/$BASEFILE"
done
cd dxf/ && rename ".pdf" ".dxf" *.pdf
It is worth mentioning that the Inkscape man page describes how to export to SVG format, and that pstoedit
also supports conversion to many other formats such as Adobe Illustrator files, plaintext, or even PowerPoint!