CAD to SVG converter Viewbox issue

Discuss and ask questions about CAD DLL (CAD Image DLL, CAD Importer DLL).

Moderators: support, SDS, admin

Post Reply
Posts: 1
Joined: 15 Jul 2015, 13:24

CAD to SVG converter Viewbox issue

Post by kalidas » 13 Oct 2015, 11:19


I am using CADImage.dll for converting cad files to svg
I observed that the viewbox created by svg file is static that is 0 0 65555 65555
but that file has points beyond the viewbox ie. 475614 like something.
so I cant view that file into browser
my browser shows me blank.

When I change the viewbox size manually as more than the points used in file, then it is visible.
So I want this viewbox size should be dynamic instead static.

let me know if I need to change the code any where,
here is my code:

public string CADToSVG(string filePath)
CADImageDLLImporter.CADFile = CADImageDLLImporter.CreateCAD(IntPtr.Zero, filePath);
if (CADImageDLLImporter.CADFile != IntPtr.Zero)
var tempFilesDirectory = ConfigurationManager.AppSettings["TempFilesDirectory"]; //Where all the temp files are
var FileName = Server.MapPath(String.Format(@"~\{0}\tmp.svg", tempFilesDirectory)); //The temp PDF path
ExportParams exportParams = new ExportParams();
exportParams.Version = "1.0";
exportParams.FileName = FileName;
exportParams.Ext = System.IO.Path.GetExtension(exportParams.FileName);

exportParams.CADParametrs.XScale = 10;
exportParams.CADParametrs.ColorBackground = Color.White;
exportParams.CADParametrs.ColorDefault = Color.Black;

//enum PixelFormat {pfDevice, pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit, pf32bit, pfCustom};
exportParams.GraphicParametrs.PixelFormat = 6; //pf24bit
exportParams.GraphicParametrs.DrawMode = (int)drawMode.dmNormal;
exportParams.GraphicParametrs.Width = CADImageDLLImporter.fAbsWidth;
exportParams.GraphicParametrs.Height = CADImageDLLImporter.fAbsHeight;
exportParams.GraphicParametrs.DrawRect = new Rect(Rectangle.Round(DrawRect));

string xmlExportParamsString = exportParams.ToString();
string graphicParams = String.Format("<GraphicParametrs><PixelFormat>1</PixelFormat><Width>{0}</Width><Height>{1}</Height><DrawMode>0</DrawMode><DrawRect Left=\"0\" Top=\"0\" Right=\"{2}\" Bottom=\"{3}\"/></GraphicParametrs>", (int)CADImageDLLImporter.fAbsWidth, (int)CADImageDLLImporter.fAbsHeight, (int)CADImageDLLImporter.fAbsWidth, (int)CADImageDLLImporter.fAbsHeight);
string cadParams = String.Format("<CADParametrs><BackgroundColor>{0}</BackgroundColor><DefaultColor>{1}</DefaultColor><XScale>1</XScale></CADParametrs>", ColorTranslator.ToWin32(Color.White), ColorTranslator.ToWin32(Color.Black));
string xmlExportParamsString = String.Format("<?xml version=\"1.0\" encoding=\"utf-16\" ?><ExportParams><Filename>{0}</Filename><Ext>{1}</Ext>" + cadParams + graphicParams + "</ExportParams>", FileName, System.IO.Path.GetExtension(FileName));
if (CADImageDLLImporter.SaveCADtoFileWithXMLParams(CADImageDLLImporter.CADFile, xmlExportParamsString, null/*OnCADProgress*/) == 0)
string ErrMsg = new string(new char[256]);
return System.IO.File.ReadAllText(FileName);
catch (Exception e)
return null;
else {
string ErrMsg = new string(new char[256]);
return null;
return null;

Posts: 2930
Joined: 30 Mar 2005, 11:36

Re: CAD to SVG converter Viewbox issue

Post by support » 13 Oct 2015, 19:26


Currently it is not possible to alter the viewBox value for the output SVG file. We are aware of this issue.

Technical Support E-mail:
Chat support on Skype:

Post Reply