Each page in Print Preview is a Metafile image, so that you can easily draw it on every canvas including bitmap canvas.
The following procedure draws pages of Print Preview on a 800x3200 pixels bitmap, then convert the bitmap to JPEG, and then save it in to a file.
- Code: Select all
procedure SavePagesAsJPEG(PrintPreview: TPrintPreview; const FileName: String);
var
Bitmap: TBitmap;
Rect: TRect;
H, I: Integer;
JPEG: TJPEGImage;
begin
Bitmap := TBitmap.Create;
try
// draw pages on the bitmap
Bitmap.Width := 800;
Bitmap.Height := 3200;
H := Bitmap.Height div PrintPreview.TotalPages;
SetRect(Rect, 0, 0, Bitmap.Width, H);
for I := 1 to PrintPreview.TotalPages do
begin
Bitmap.Canvas.StretchDraw(Rect, PrintPreview.Pages[I]);
OffsetRect(Rect, 0, H);
end;
// convert bitmap to jpeg, and save it to file
JPEG := TJPEGImage.Create;
try
JPEG.Assign(Bitmap);
JPEG.JPEGNeeded;
JPEG.SaveToFile(FileName);
finally
JPEG.Free;
end;
finally
Bitmap.Free;
end;
end;
Here, you will see print preview pages in General Demo as JPEG image that is created using the above procedure. To have 4 pages like your case, I set paper size in General Demo to "A5 Rotated".
- JPEG image of all print preview pages.
- Pages.jpg (247.38 KiB) Viewed 1141 times