Copy TsgCADImage to metafile
Posted: 27 Apr 2015, 09:55
I'm trying to overcome a problem in using CADImportVCL with Report Builder.
The problem (in v 6.1 and v9.1) is that loading a .DWG into a Report Builder ppImage causes any text to be rendered incorrectly on the report canvas.
In 6.1, DXFs did not affect text renders correctly.
In 9.1, anything descended from TCADImage causes text to be incorrectly placed on the canvas.
My workaround in 6.1 for DWG images was to load the drawing into a temporary TsgDWGImage, convert this to metafile, then assign the metafile to the ppImage:
When I try this in v9.1, the drawings are not rendered at all (appear to be blank, not 'nil').
That is, the following (almost exactly the same code) does not work in v9.1:
I've tried with sgConsts.KeepOriginal:=true; - no difference in behaviour.
Given that the problem with rendering text has been around for awhile, I'm thinking it will be quicker to figure out how to fix the workaround.
Can someone suggest how I might be able to get the above working?
Thanks!
The problem (in v 6.1 and v9.1) is that loading a .DWG into a Report Builder ppImage causes any text to be rendered incorrectly on the report canvas.
In 6.1, DXFs did not affect text renders correctly.
In 9.1, anything descended from TCADImage causes text to be incorrectly placed on the canvas.
My workaround in 6.1 for DWG images was to load the drawing into a temporary TsgDWGImage, convert this to metafile, then assign the metafile to the ppImage:
Code: Select all
vDWG := TsgDWGImage.Create ; // vDWG is type TsgDWGImage
try
vDWG.LoadFromFile(fName);
vDWG.IsWithoutBorder:=True;
vDWG.BackgroundColor:=clWhite;
vDWG.DefaultColor:=clBlack;
vDWG.UseWinEllipse:=True;
vDWG.DrawMode:= dmBlack;
vDWG.NullWidth:=0;
vDWG.IsShowLineWeight:=True;
vDWG.LineScaled:=true;
vDWG.GetExtents;
mf := vDWG.ExportToMetafile(3276700);
ppImage1.Picture.Metafile:= mf;
finally
mf.Free;
vDWG.Free;
end;
That is, the following (almost exactly the same code) does not work in v9.1:
Code: Select all
vDWG := TsgCADImage.Create ; // vDWG is type TsgCADImage - the only change...
try
vDWG.LoadFromFile(fName);
vDWG.IsWithoutBorder:=True;
vDWG.BackgroundColor:=clWhite;
vDWG.DefaultColor:=clBlack;
vDWG.UseWinEllipse:=True;
vDWG.DrawMode:=dmBlack;
vDWG.NullWidth:=0;
vDWG.IsShowLineWeight:=True;
vDWG.LineScaled:=true;
vDWG.GetExtents;
mf := vDWG.ExportToMetafile(3276700);
ppImage1.Picture.Metafile:= mf;
finally
mf.Free;
vDWG.Free;
end;
I've tried with sgConsts.KeepOriginal:=true; - no difference in behaviour.
Given that the problem with rendering text has been around for awhile, I'm thinking it will be quicker to figure out how to fix the workaround.
Can someone suggest how I might be able to get the above working?
Thanks!