Question: I am building a back-end management application for an architect company, and they work with DWG files. I am looking for a library that can convert DWG into any image format, preferably in PHP, but I am open to finding a work around in another language and connecting to what I've built so far. Is there any solution on VeryDOC?
Answer: Now on VeryDOC there is command line software which can help you convertin any standard image format without any third party installed. However, now there is no API or library which can help you do that. If you need, please tell us then we can customize one API to library quite fast. By the command line version software, you can also run the conversion from the PHP code. In the following part, I will take the command line version for example to show you how it works. If you feel it is good then we will make the API or library for you.
The software I refer to is named as VeryDOC DWG to Image Converter by which you can convert DWG and DXF files to Raster BMP, JPG, PNG, TIFF, GIF formats. This converter can help you create output file for each view, one output file per view. It supports all version DWG files and allows you to run the conversion in batch.
Step 1. Free download DWG to Image Converter Command Line
- When downloading finishes, there will be a zip file. Please extract it to some folder then you can call it from MS Dos Windows.
- When you run the conversion, please refer to the usage and example.
- Please note this is Window version application, for now it only can work under Window system.
Step 2. Convert.
- Usage: dwg2img [options] <dwg-file> [<out-file>]
- For converting , please refer to the following command line template and parameters:
- When you call it from PHP code, please refer to the following code template:
fontdir <string> : a folder contain .ctb, .shx, etc. files
-dpi <int> : set DPI to output file
-width <int> : set width, unit is point
-height <int> : set height, unit is point
-linewidth <string>: set line width, unit in mm
-colormode <int> : set color mode, 0 is color and 1 is black and white
-bgcolor <int> : set background color, same as AutoCAD color index
-zoomtype <int> : set zoom type, 1 is 'Zoom All' and 2 is 'Zoom Extend'
-$ <string> : input registration key
dwg2img.exe C:\test.dwg C:\out.bmp
dwg2img.exe C:\test.dwg C:\out.jpg
dwg2img.exe C:\test.dwg C:\out.gif
dwg2img.exe C:\test.dwg C:\out.png
dwg2img.exe C:\test.dwg C:\out.tif
dwg2img.exe C:\*.dwg C:\*.png
$exeshell =new COM("exeshell.shell") or die("Can't start exeshell");
$exeshell->RunCommandLine("UserName", "Password", ' "C:\dwg2img.exe" "C:\test.dwg" "C:\out.tif" ');
$exeshell = null;
During the using, if you have new idea or problem, please contact us as soon as possible.