Formatting metafiles in TRichView

General TRichView support forum. Please post your questions here
Post Reply
voodoo
Posts: 3
Joined: Tue May 23, 2006 1:24 pm

Formatting metafiles in TRichView

Post by voodoo »

Hi,
I load several metafiles into a RichView, page breaking each one so I have one metafile per page.

Code: Select all

begin
  TheRichView.Clear;
  for i:=1 to pp do
  begin
      gr := TMetafile.Create;

      pic.Picture.LoadFromFile('C:\Temp\'+WFilePrefix+Format('%4.4d',[i])+'.WMF');
      
      pic.Width:=ThePreview.AreaWidth;
      
      gr.Assign(pic.Picture);

      TheRichView.AddPictureEx('',gr,0,rvvaBaseline);

      TheRichView.AddBreak;

  end;
end;
I want to reformat them to be correctly viewed (and printed) into a TRVPrintPreview (linked to a RVPrint) control. I've attempted several ways to do this but without success.The metafiles are always too much big in width (they are clipped on the right).

Could you help me?

Thanks.

Robert
voodoo
Posts: 3
Joined: Tue May 23, 2006 1:24 pm

Post by voodoo »

Pratically, I want resize every metafile to fit into the preview area (one for each page and considering preview margins) and then print them to a printer. For the preview I've not found any property like PageWidth so I don't know how to fit the files into the previewer. I've modified the previous source with the following:

Code: Select all

TheRichView.Clear;

  for i:=1 to pp do
  begin

      gr := TMetafile.Create;

      pic.Picture.LoadFromFile('C:\Temp\'+WFilePrefix+Format('%4.4d',[i])+'.WMF');

      gr.Assign(pic.Picture);

      TheRichView.AddPictureEx('',gr,0,rvvaBaseline);

      TheRichView.SetItemExtraIntProperty(TheRichView.ItemCount-1,
                                          rvepImageWidth,
                                          ThePreview.AreaWidth);
 
     therichview.PageBreaksBeforeItems[TheRichView.ItemCount-1]:=TRUE;

end;
... but in the SetItemExtraIntProperty call I don't know what is the AreaWidth property of the previewer(I've made an attempt...). With this param the metafile width is too small (3/4 of the previewer area).
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

See this topic for the procedure returning width and height of printing area: http://www.trichview.com/forums/viewtopic.php?t=559
Post Reply