Page 1 of 1

Pictures in an RTF files

Posted: Wed Apr 11, 2007 7:06 pm
by topcat
Hi,

I am using the following code to open RTF file from a memory stream:

Code: Select all

      RichViewedit1.Clear;
      RichViewedit1.LoadRTFFromStream(MyStream);
      RichViewEdit1.Format;
The RTF files that I am opening contain pictures. I have noticed that by default the pictures are not scaled to 100% (original size).

Is there an option to automatically scale all pictures in an RTF file to 100% prior to being displayed to the user?

Thanks for your time

[/code]

Posted: Thu Apr 12, 2007 5:25 am
by Sergey Tkachenko
Do you want to ignore picture scaling specified in RTF and display all pictures in their original size?

Use the following procedure:

Code: Select all

procedure ResetPicSize(RVData: TCustomRVData);
var i,r,c: Integer;
    Table: TRVTableItemInfo;
begin
  for i := 0 to RVData.ItemCount-1 do
    case RVData.GetItemStyle(i) of
      rvsTable:
        begin
          Table := TRVTableItemInfo(RVData.GetItem(i));
            for r := 0 to Table.RowCount-1 do
              for c := 0 to Table.ColCount-1 do
                if Table.Cells[r,c]<>nil then
                  ResetPicSize(Table.Cells[r,c].GetRVData);
        end;
      rvsPicture, rvsHotPicture:
        begin
          RVData.SetItemExtraIntProperty(i, rvepImageWidth, 0);
          RVData.SetItemExtraIntProperty(i, rvepImageHeight, 0);
        end;
    end;
end;
Call:

Code: Select all

      RichViewedit1.Clear; 
      RichViewedit1.LoadRTFFromStream(MyStream); 
      ResetPicSize(RichViewEdit1.RVData);
      RichViewEdit1.Format;

Posted: Thu Apr 12, 2007 8:28 am
by topcat
Thankyou for the prompt response, I will try that.

Posted: Thu Apr 12, 2007 7:41 pm
by topcat
Worth every penny, Thanks!

For those wanting to use the above code ensure you have the following in your USES

CRVData, RVTable, RVItem;