LPrint::Print

Summary

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

Syntax

#include "ltwrappr.h"

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

Parameters

HDC 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.

L_INT nX

X position to start the print. Pass a 0 to center the image horizontally on the page.

L_INT nY

Y position to start the print. Pass a 0 to center the image vertically on the page.

L_INT 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.

L_INT 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.

L_BOOL 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

Value Meaning
>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

See Also

Functions

Topics

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 22.0.2023.2.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.