Page 1 of 1

Formatting metafiles in TRichView

Posted: Mon May 29, 2006 8:53 am
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

Posted: Mon May 29, 2006 1:53 pm
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).

Posted: Tue May 30, 2006 1:00 pm
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