PrintNewPage Example for C++ Builder
float HeightFactor, WidthFactor, HeightAllowed, WidthAllowed;
float ControlWidth, ControlHeight;
long MyPrinter;
LEADRasterIO* pRasterIO= NULL;
LEADRasterProcess* pRasterProc= NULL;
CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL, IID_ILEADRasterIO, (void**)&pRasterIO);
CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL, IID_ILEADRasterProcess, (void**)&pRasterProc);
//change this to a file on your system
pRasterIO->Load (LEADRasterView1->Raster, AnsiToOLESTR("v:\\images\\babe.cmp"), 0, 1, 1);
//note, there will be no samples for other platforms, this function is not necessary in other languages):
//Set the variables used for preserving the aspect ratio->
HeightFactor= LEADRasterView1->Raster->BitmapHeight;
WidthFactor= LEADRasterView1->Raster->BitmapWidth;
//Allow a maximum of 3x3 inches on a 300dpi printer
HeightAllowed= 900;
WidthAllowed= 900;
//Print the LEAD control, preserving the aspect ratio->
//Check to see if was using the maximum width will make the image too tall->
//Set the dimensions based on the result->
if (((WidthAllowed * HeightFactor) / WidthFactor) < HeightAllowed )
{
ControlWidth= WidthAllowed;
ControlHeight= (ControlWidth * HeightFactor) / WidthFactor;
}
else
{
ControlHeight= HeightAllowed;
ControlWidth= (ControlHeight * WidthFactor) / HeightFactor;
}
//start the print job
MyPrinter= LEADRasterView1->PrintStart ();
LEADRasterView1->Render (MyPrinter, 0, 0, ControlWidth, ControlHeight);
//flip the image
pRasterProc->Flip (LEADRasterView1->Raster);
//start a new page
LEADRasterView1->PrintNewPage (MyPrinter);
//print the flipped image
LEADRasterView1->Render (MyPrinter, 0, 0, ControlWidth, ControlHeight);
//end the print job
LEADRasterView1->PrintEnd (MyPrinter);
pRasterProc-> Release( );
pRasterIO-> Release( );