virtual HDC LPrint::Print(hDC=NULL, nX=0, nY=0, nWidth=0, nHeight=0, bEndDoc=TRUE)
Prints the associated class object's bitmap to the specified device.
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.
X position to start the print. Pass a 0 to center the image horizontally on the page.
Y position to start the print. Pass a 0 to center the image vertically on the page.
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.
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.
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. |
Value | Meaning |
---|---|
>0 | Function was successful. If bEndDOC is FALSE, the return value is the printer HDC. |
0 | An error occurred. |
You can specify the position and dimensions of the printed image, or let the function calculate values for you as follows:
You can specify the X and Y offsets of the image, or you can let the function center the image vertically, horizontally, or both.
You can specify the width, and let the function calculate the height to preserve the aspect ratio.
You can specify the height, and let the function calculate the width to preserve the aspect ratio.
You can let the function calculate the maximum printed width and height, while preserving the aspect ratio.
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.
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 Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document