Available in the LEADTOOLS Imaging toolkit. |
RenderCenter example for C++ 5.0 and later
HDC hdcPrinter;
PRINTDLG printdlg;
DOCINFO docinfo;
// get and prepare the printer DC
memset( &printdlg, 0, sizeof(printdlg) );
printdlg.lStructSize = sizeof(printdlg);
printdlg.Flags = PD_RETURNDC;
if( !PrintDlg(&printdlg) )
return;
if( (hdcPrinter = printdlg.hDC) == NULL )
{
if( printdlg.hDevMode ) GlobalFree(printdlg.hDevMode);
if( printdlg.hDevNames) GlobalFree(printdlg.hDevNames);
return;
}
docinfo.cbSize = sizeof(docinfo);
docinfo.lpszDocName = "Print example using LEADTOOLS.";
docinfo.lpszOutput = NULL;
docinfo.fwType = 0L;
if( StartDoc(hdcPrinter, &docinfo) <= 0)
{
if( printdlg.hDevMode ) GlobalFree(printdlg.hDevMode);
if( printdlg.hDevNames) GlobalFree(printdlg.hDevNames);
DeleteDC(hdcPrinter);
}
StartPage(hdcPrinter);
// print the image
TextOut( hdcPrinter, 0, 0, "Center the image on the page", strlen("Center the image on the page"));
m_LEAD1.SetRenderCenter(TRUE);
m_LEAD1.Render((long)hdcPrinter, 0, 0, m_LEAD1.GetBitmapWidth(), m_LEAD1.GetBitmapHeight());
//Finish the page and finish the print job
EndPage( hdcPrinter );
EndDoc( hdcPrinter );
//clean up
if( printdlg.hDevMode ) GlobalFree(printdlg.hDevMode);
if( printdlg.hDevNames) GlobalFree(printdlg.hDevNames);
DeleteDC(hdcPrinter);