Hello,
I need to split a metafile.
It has an a3 format and I want to split the file in two a4 metafiles so I can print it on two pages.(I use Printpreview) How can I do this?
I know how to do this with a bitmap, but not with a metafile.
There's no need to physically split the metafile.
1. Devide the metafile to some logical sections. For example to print an A3 size metafile, you should consider two A4 size sections.
2. For each section, offset origion of the destination canvas to top-left corner of the section.
3. Stretch draw the metafile on the canvas, as you print on an A3 paper. However, your actual canvas size should be A4 size.
procedure split metafile(Index:Integer);
var
BWidth, BHeight : Integer;
SrcRect, DestRect : TRect;
BlzCanvas:TCanvas;
begin
BWidth := Picture.Width div 2;
BHeight := Picture.Height div 2;
DestRect := pa4; // a4 papersize
SrcRect.Left := (Index mod 2) * BWidth;
SrcRect.Top := (Index div 2) * BHeight;
SrcRect.Right := SrcRect.Left + BWidth;
SrcRect.Bottom := SrcRect.Top + BHeight;
try
BlzCanvas := TMetafileCanvas.Create(FPicture.Metafile,0);
BlzCanvas.Draw(0 - (SrcRect.Left ),0 - (SrcRect.Top ),Picture.Metafile);
finally
BlzCanvas.Free;
end;
PreviewPrinter1.Canvas.StretchDraw(pa4,BlzCanvas);
end;
Users browsing this forum: No registered users and 18 guests