I have a .zip file with two drawings in it, but after 3 tries, I still cannot upload the file for your review.
Here is my code snippet:
Code: Select all
CADImage img = CADImage.CreateImageByExtension(strSrc);
img.UseDoubleBuffering = false;
img.LoadFromFile(strSrc);
img.SetCurrentLayout(0);
img.RefreshCurrentLayout();
img.GetExtents();
// Save a BMP and convert that to PDF - since direct save-to-pdf costs another 1.5k from CADImport.NET folks
//save raster image
if (img.Painter != null) {
Bitmap bmp = new Bitmap(1, 1);
Graphics g = Graphics.FromImage(bmp);
img.SetNewMMToPixel(g);
double scale = (img.AbsWidth / img.MMToPixelX) * 72; // assume scale is in points and scale up...
DRect r = new DRect(0, 0, scale, scale), ext = img.Extents;
System.Drawing.Imaging.ImageFormat fmtOut = System.Drawing.Imaging.ImageFormat.Png; // .ImageFormat.Bmp; //
img.ChangeDrawMode(DrawGraphicsMode.Export, null); // DrawGraphicsMode.GDIPlus, null);
// !!!!!!!!!!!!!!!!! WARNING! !!!!!!!!!!!!!!!!!
// even though it's a PNG file format, something about the .png extension causes a crash
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
img.SaveToFile(strDest + ".img", fmtOut, r);
string imgDest = strDest + ".png";
if (File.Exists(imgDest)) File.Delete(imgDest);
System.IO.File.Move(strDest + ".img", strDest + ".png");
g = null;
bmp = null;
}
I am also finding that XREFs are not being exported when I export from a .dwg file that has them.
Could these two issues be related?
Thanks for your assistance!