Error in Reading RVF Subdocument

General TRichView support forum. Please post your questions here
Post Reply
josef-b
Posts: 5
Joined: Sun Mar 15, 2015 4:45 pm

Error in Reading RVF Subdocument

Post by josef-b »

I want do load Data from Database.

Code: Select all

procedure TFemail_client.Ein_loadRichViewFromBlob;
var
BlobStream : TStream;
BlobFeld : TField;
begin
richview1.clear;

with dsein do //TIBDataset
  begin
  BlobFeld := Fieldbyname('Body_Richview');
  BlobStream := CreateBlobstream(Blobfeld,bmread);
  BlobStream.position := 0;
  Richview1.LoadRVFfromStream(BlobStream);
  end;

RichViewEin.format;
I'm getting error: Error in Reading RVF Subdocument, TD.c.Data Error in Reading Subdocument RVF.

I tried to save to File and load again. It shows the same problem.

Data contains Hyperlinks and Pictures like in mime emails
Sergey Tkachenko
Site Admin
Posts: 17236
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Error in Reading RVF Subdocument

Post by Sergey Tkachenko »

This error happens when an error occurred while reading a table cell.

I opened your RVF file in the ActionTest project compiled with the new version of TRichView. It was loaded successfully.

Your document contains PNG classes that were stored in TdxPNGImage class.
If you use new version of TRichView, it is not a problem, even if the application that loads this file does not use TdxPNGImage: if it cannot create a graphic class specified in RVF, it detects the image format by content and uses the appropriate graphic class (for PNG image, it is usually TPngImage).

But if you use old version of TRichView, you need to register all graphic classes used in RVF document:

Code: Select all

RegisterClasses([TdxSmartImage, TdxPNGImage]).
Call RegisterClasses one time before the first RVF loading.
josef-b
Posts: 5
Joined: Sun Mar 15, 2015 4:45 pm

Re: Error in Reading RVF Subdocument

Post by josef-b »

My Version is 17.4.2 Is there a newer one?

I bought it from you this month.

Now I tried:

Code: Select all


procedure TFemail_Client.FormCreate(Sender: TObject);
begin
RegisterClasses([TdxSmartImage, TdxPNGImage]);
......
I tried to load the same rvf, but I have the same error. :(
Sergey Tkachenko
Site Admin
Posts: 17236
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Error in Reading RVF Subdocument

Post by Sergey Tkachenko »

17.4.2 is the newest version.

Please create a simple project reproducing this problem and send it to me.
josef-b
Posts: 5
Joined: Sun Mar 15, 2015 4:45 pm

Re: Error in Reading RVF Subdocument

Post by josef-b »

Here I'm sending sample project, without RVF. Do you still have my RichView_Test.rvf including the problem?

It is too long for sending it here.

I sent it completey by email (gmail).
Attachments
TRichView_Problem_o_rvf.zip
(120.17 KiB) Downloaded 955 times
Sergey Tkachenko
Site Admin
Posts: 17236
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Re: Error in Reading RVF Subdocument

Post by Sergey Tkachenko »

The reason of this error: TRichView cannot read GIF images from this document, because a graphic class for Gif images is not defined.
This RVF file contains Png and Gif images. While TRichView uses TPngImage for Png (for Delphi 2009+), a class for Gif images is not defined by default.

Possible solutions:

1) Include RVGifAnimate2007 in "uses" of this form. This unit associates the standard TGifImage class with gif images, and adds special support for displaying animated gifs.
So, Png images will be loaded in TPngImage, Gif images will be loaded in TGifImage.

2) You can re-define default classes which TRichView uses for Gif and Png images:

Code: Select all

uses
  RVFuncs, RVGrHandler;
...
  RVGraphicHandler.SetDefaultGraphicClass(rvgtGif, TdxSmartImage);
  RVGraphicHandler.SetDefaultGraphicClass(rvgtPng, TdxPNGImage);
If you decide to use TdxPNGImage, it's better to add RVUSEDXPNGIMAGE to $defines of your project, some special support for TdxPNGImage and TdxSmartImage will be added.
But, actually, I do not see advantages of this approach, and it lacks of gif animation, so I recommend using TPngImage and TGifImage.

3) You can include rvfoIgnoreUnknownPicFmt in RVFOptions. With this option, images of unsupported formats will not generate an error, but will be replaced to RVStyle.InvalidPicture.

PS: if LoadRVF returns false, format the document first, and only then display an error message. Failed LoadRVF can still read a part of RVF document, and it will be unformatted until you call Format.
Post Reply