## Splitting a Metafile

Please discuss general Delphi programming topics here.

### Splitting a Metafile

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.
Feike
Active Member

Posts: 6
Joined: August 2nd, 2006, 8:10 am
Location: Netherlands

it's scallable vector graphics, meaning that it would scale itself to proper width and height. but spit in in two pages? only some grahics programs came to my mind, eg corel or inkscape
Johnny_Bit
VIP Member

Posts: 455
Joined: June 15th, 2003, 9:56 am

but spit in in two pages? only some grahics programs came to my mind, eg corel or inkscape

So it can't be done in Delphi?
Feike
Active Member

Posts: 6
Joined: August 2nd, 2006, 8:10 am
Location: Netherlands

And you know how hard it's done? Sime way wouldbe draw metafile on bitmap then split bitmap, as I am no expert when it commes to metafiles i think that best wa to do it without bitmap wouldbe fixed-point scale and then place virtual ruller on middle, then cut objects along it. but how, I don't know
Johnny_Bit
VIP Member

Posts: 455
Joined: June 15th, 2003, 9:56 am

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.
That's all.
Kambiz

Kambiz
Administrator

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

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.

How can I devide a canvas in sections?
Can you give some more info?
Thanks in advance
Feike
Active Member

Posts: 6
Joined: August 2nd, 2006, 8:10 am
Location: Netherlands

Feike wrote:How can I devide a canvas in sections?

In the same way you divide a paper; by measuring and locating the right coordinates.
Kambiz

Kambiz
Administrator

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Is this what you mean?

Code: Select all
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;
Feike
Active Member

Posts: 6
Joined: August 2nd, 2006, 8:10 am
Location: Netherlands

Yes!

You do not need BlzCanvas.
Kambiz

Kambiz
Administrator

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

I tried this and it works!

Thanks for your help!
Feike
Active Member

Posts: 6
Joined: August 2nd, 2006, 8:10 am
Location: Netherlands

Return to Delphi Programming

### Who is online

Users browsing this forum: No registered users and 1 guest