PrintNewPage Example for Delphi
var
HeightFactor, WidthFactor, HeightAllowed, WidthAllowed: Single;
ControlWidth, ControlHeight: Single;
MyPrinter: longint;
nRet: Integer;
sRet: Smallint;
RasterIO: LEADRasterIO;
RasterProc: LEADRasterProcess;
begin
RasterIO:= CreateComObject (CLASS_LEADRasterIO) as LEADRasterIO;
RasterProc:= CreateComObject (CLASS_LEADRasterProcess) as LEADRasterProcess;
//change this to a file on your system
RasterIO.Load (LEADRasterView1.Raster, '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 ) then
begin
ControlWidth:= WidthAllowed;
ControlHeight:= (ControlWidth * HeightFactor) / WidthFactor;
end
else
begin
ControlHeight:= HeightAllowed;
ControlWidth:= (ControlHeight * WidthFactor) / HeightFactor;
end;
//start the print job
MyPrinter:= LEADRasterView1.PrintStart (nRet);
LEADRasterView1.Render (MyPrinter, 0, 0, ControlWidth, ControlHeight, sRet);
//flip the image
RasterProc.Flip (LEADRasterView1.Raster);
//start a new page
LEADRasterView1.PrintNewPage (MyPrinter);
//print the flipped image
LEADRasterView1.Render (MyPrinter, 0, 0, ControlWidth, ControlHeight, sRet);
//end the print job
LEADRasterView1.PrintEnd (MyPrinter);
end;