LPrint::Print

#include "ltwrappr.h"

virtual HDC LPrint::Print(hDC=NULL, nX=0, nY=0, nWidth=0, nHeight=0, bEndDoc=TRUE)

HDC hDC;

handle to the device context (DC)

L_INT nX;

x position to start the print

L_INT nY;

y position to start the print

L_INT nWidth;

printed width

L_INT nHeight;

printed height

L_BOOL bEndDoc;

flag that indicates whether to print another image on the page

Prints the associated class object's bitmap to the specified device.

Parameter Description
hDC Handle to the device context (DC) where the bitmap is to print. The mapping mode of the device context must be MM_TEXT. If this is NULL, then the bitmap will be printed to the default device context.
nX X position to start the print. Pass a 0 to center the image horizontally on the page.
nY Y position to start the print. Pass a 0 to center the image vertically on the page.
nWidth The printed width. The value is in dots, and the actual width depends on the dots per inch (DPI) of the printer.
  Pass a 0 to let the function calculate the width. If you specify only the width or only the height, the function calculates the remaining dimension. If you pass zeros for both width and height, the function calculates the maximum dimensions that fit on the page while preserving the aspect ratio.
nHeight The printed height. The value is in dots, and the actual height depends on the dots per inch (DPI) of the printer.
  Pass a 0 to let the function calculate the height. If you specify only the width or only the height, the function calculates the remaining dimension. If you pass zeros for both width and height, the function calculates the maximum dimensions that fit on the page while preserving the aspect ratio.
bEndDoc Flag that indicates to LEADTOOLS whether you plan to print another image on the same page or not. Possible values are:
  Value Meaning
  TRUE LEADTOOLS will free the hDC and send a paper eject.
  FALSE LEADTOOLS will assume that you plan to print another bitmap.

Returns

>0

Function was successful. If bEndDOC is FALSE, the return value is the printer HDC.

0

An error occurred.

Comments

You can specify the position and dimensions of the printed image, or let the function calculate values for you as follows:

The function is designed to let you print multiple bitmaps on the same page. To do so, call the function with the fEndDoc argument set to FALSE for each image except the last one on the page. Then call the function with the fEndDoc argument set to TRUE. If you do not set the fEndDoc argument to TRUE on the last call, the hDC will not be freed, and the page will not flush.

If fEndDOC is FALSE, you can use the returned hDC to draw to the current printer page.

An alternative for greater flexibility is the LPaint::PaintDC function, which you can use by specifying the printer as the display surface.

Required DLLs and Libraries

LTDIS

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LPrint::PrintFast, LPrint::PrintGDIPlus, Class Members

Topics:

Raster Image Functions: Printing Images

Example

L_INT LPrint__PrintExample() 
{ 
   L_INT nRet; 
   LBitmapBase MyBitmap; 
   LPrint MyPrint; 
   HDC hPrinterDC; 
 
   nRet = MyBitmap.Load(MAKE_IMAGE_PATH(TEXT("Image1.cmp"))); 
   if(nRet != SUCCESS) 
      return nRet; 
 
   MyPrint.SetBitmap(&MyBitmap); 
 
   hPrinterDC = MyPrint.GetPrinterDC(); 
 
   if(MyPrint.IsValid()&&hPrinterDC) 
   { 
      if(MyPrint.PrintFast(hPrinterDC) == 0) 
         return FAILURE; 
   } 
 
    if(MyPrint.Print() == 0) 
       return FAILURE; 
 
    return SUCCESS; 
} 
Help Version 20.0.2020.4.5
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help