Pictures in an RTF files

General TRichView support forum. Please post your questions here
Post Reply
topcat
Posts: 8
Joined: Wed Apr 11, 2007 6:50 pm

Pictures in an RTF files

Post 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]
Sergey Tkachenko
Site Admin
Posts: 17565
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
topcat
Posts: 8
Joined: Wed Apr 11, 2007 6:50 pm

Post by topcat »

Thankyou for the prompt response, I will try that.
topcat
Posts: 8
Joined: Wed Apr 11, 2007 6:50 pm

Post 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;
Post Reply