Hopefully this will save someone else time and effort...
Cheers,
EdB
-----------------------------------------------------------------
Subject: Using AutoCAD files with RB
Newsgroups: digital-metaphors.public.reportbuilder.general
Having spend a longish amount of time on this, I thought I'd document
this for the group...
I'm using a library called CADImportVCL from http://www.cadsofttools.com to
process DWG, DXF, and even HPGL, EMF etc files.
To print drawings with RB - say as a full page drawing in a header, do
the following:
1) create a new registration unit
Code: Select all
unit ppCustomDXF;
interface
{$I ppIfDef.pas}
uses ppCtrls,
DXFImage; // from CADImportVCL
implementation
initialization
ppRegisterGraphicClass('DXF', TsgDXFImage);
ppRegisterGraphicClass('DWG', TsgDXFImage);
finalization
ppUnRegisterGraphicClass(TsgDXFImage);
end.
Code: Select all
uses
...
DWG, DXFImage, ppCustomDXF,
...;
for 8.5x11 sheet then set for 10.5 wide x 8.0 high)
4) drop a ppImage on the header band, set position to top=0, left=0,
width=10.5, height=8.0
Set ppImage properties as:
Code: Select all
Autosize=false
DirectDraw=TRUE
MaintainAspectRatio=true
Stretch=true
Code: Select all
<b>procedure</b> TForm1.ppHeaderBand1BeforePrint( Sender: TObject);
<b>var</b>
fName: <b>string</b>;
<b>begin</b>
fName:= GetDrawingFileNameSomehowOrOtherThatsYourProblem; // <g>
ppImage1.Picture.LoadFromFile(fName);
TsgDXFImage(ppImage1.Picture.Graphic).BackgroundColor:=clWhite;
TsgDXFImage(ppImage1.Picture.Graphic).IsWithoutBorder:=true;
// UseWinEllipse sometimes gives smoother arcs
TsgDXFImage(ppImage1.Picture.Graphic).UseWinEllipse:=true;
// set minium line width for "null width lines"
TsgDXFImage(ppImage1.Picture.Graphic).NullWidth:=1;
// set drawing mode - dmNormal=colour, dmGray=GrayScale, dmBlack= B/W
TsgDXFImage(ppImage1.Picture.Graphic).DrawMode:=dmGray;
TsgDXFImage(ppImage1.Picture.Graphic).GetExtents;
<b>end</b>;
PixelsPerInch around 150 to get nice clean printing PDF, and make sure
PDF ScaleImages = true.