about printer

Discuss and ask questions about CAD VCL (Delphi and C++ Builder).

Moderators: SDS, support, admin

Post Reply
allen
Posts: 5
Joined: 03 Dec 2015, 06:21

about printer

Post by allen » 03 Dec 2015, 06:45

Hello! Print how to select range

example autodesk dwg truview : what to plot "windows"

Thank you

Image

support
Posts: 3253
Joined: 30 Mar 2005, 11:36
Contact:

Re: about printer

Post by support » 03 Dec 2015, 21:06

Hello Allen,

We recommend to use a TsgDrawingNavigator component for plotting a rectangular area selected with the mouse. To accomplish this, follow the steps below:

1) Load a drawing file into the TsgDrawingNavigator:

Code: Select all

FDNavigator.LoadFromFile(OpenPictureDialog1.FileName);

2) Activate the ClipRectangle mode to be able to select an area of the drawing to be plotted:

Code: Select all

FDNavigator.ClipRectangle := True
3) Select an area to be plotted with the mouse. When the area is selected, you can obtain the portion of the drawing bounded by the clipping rectangle as TGraphic object using a TsgDrawingNavigator.ActualGraphic property.

4) Use the Printer function to get access to the global TPrinter object and draw the given TGraphic on a page, as in the example below.

Code: Select all

uses  
  Windows, Graphics, Dialogs, ..., Printers;


procedure PrintImage(AGraphic: TGraphic);

const PO: array[Boolean] of TPrinterOrientation = (poPortrait, poLandscape);
var
  W, H: Double;
  PW, PH: Integer;
  R: TRect;
begin
  with Printer do
  begin
    Orientation := PO[AGraphic.Width > AGraphic.Height];
    W := PageWidth / AGraphic.Width;
    H := PageHeight / AGraphic.Height;
    if W > H then W := H;
    PW := Round(W * AGraphic.Width);
    PH := Round(W * AGraphic.Height);
    R := Bounds((PageWidth - PW) div 2, (PageHeight - PH) div 2, PW, PH);
    Printer.BeginDoc;
    try
      Printer.Canvas.StretchDraw(R, AGraphic);
    except
      Printer.EndDoc;
      ShowMessage('Problem while printing, please try again.');
    end;
    Printer.EndDoc;
  end;
end;

...

PrintImage(FDNavigator.ActualGraphic);
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

Post Reply