Using CADImportVCL with Report Builder

The forum is for all developers who are using CADSoftTools products. If you encounter some issue or have a question regarding the development, you can ask for other developers help.

Moderators: SDS, support, admin

Post Reply
edbored
Posts: 20
Joined: 26 Jul 2005, 00:15
Location: Canada

Using CADImportVCL with Report Builder

Post by edbored » 26 Jul 2005, 22:51

This is a copy of a message posted to Report Builder newsgroup.
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.
2) include new registration unit and Cad soft units in report form

Code: Select all

   uses
   ...
   DWG, DXFImage, ppCustomDXF,
   ...;
3) set your header band to the printable size of page (eg if landscape
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
5) in the header band onBeforePrint event set:

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>;
Note that if you use Waler TExtraDevices, you'll have to set the PDF
PixelsPerInch around 150 to get nice clean printing PDF, and make sure
PDF ScaleImages = true.

edbored
Posts: 20
Joined: 26 Jul 2005, 00:15
Location: Canada

Re: Using CADImportVCL with Report Builder

Post by edbored » 05 Apr 2013, 04:07

Follow-up...

I (finally) upgraded my copy of Report Builder from RBPro 7.04 to RBPro 14.08.

In order to get my report to work with the new RB version, I had to set the ppReport to the 'old page view style'.

ppReport1.PreviewFormSettings.SinglePageOnly := true;

The default is false - to "...enable the new scrollable page preview, which generates pages in a background thread. This can cause threading issues in some cases..."

Cheers,
EdB

Post Reply