Code sample Home

Print drawing's extents at paper's center
void DemoPrint (HANDLE hLcWnd)
{
  HANDLE hBlock;
  double X, Y, W, H, Scale, scw, sch;
  double PapW, PapH, PapLef, PapTop, Gap, w2, h2;

  // set printer paper parameters
  PapW = 210.0;  // paper width
  PapH = 297.0;  // paper height
  Gap = 10.0;    // border gap

  // get a block, linked with CAD window
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );

  // get block's extents
  X = lcPropGetFloat( hBlock, LC_PROP_BLOCK_XMIN );
  Y = lcPropGetFloat( hBlock, LC_PROP_BLOCK_YMIN );
  W = lcPropGetFloat( hBlock, LC_PROP_BLOCK_DX );
  H = lcPropGetFloat( hBlock, LC_PROP_BLOCK_DY );

  // size of work area on a paper
  w2 = PapW - Gap - Gap;
  h2 = PapH - Gap - Gap;
  // calculate print scale, <printer mm> / <drawing units>
  scw = w2 / W;
  sch = h2 / H;
  if (scw < sch){
    Scale = scw;
    // set origin of print area on a paper
    PapLef = Gap;
    PapTop = (PapH / 2.0) - (H / 2.0 * Scale);
  }else{
    Scale = sch;
    // set origin of print area on a paper
    PapTop = Gap;
    PapLef = (PapW / 2.0) - (W / 2.0 * Scale);
  }
  // print 
  lcPrintBlock( hBlock, X, Y, W, H, Scale, PapLef, PapTop ); 
}

Used functions:

lcPrintBlock
lcPropGetHandle
lcPropGetFloat