|
Linked Images |
Top Previous Next |
|
Linked images use the string propetry StreamName to identify their contents. If this property is <>"" the binary image data will not be saved in a document fromat which othewise allows embedding, such as RTF and WPT. To HTML images can only be saved if a "StreamName" is provided.
The event OnHTTPRequestImage is used to load the image data for images placed in HTML code and also for linked images loaded in RTF or WPT format. This event should be used to load images from a database which are only referenced in the text blob.
Please read the FAQ at http://wpcubed.com/forum/viewtopic.php?p=3287#3287
The event OnPrepareImageforSaving can be used to create image files (or database records) for images which are embedded.
procedure TForm1.WPRichText1RequestHTTPImage(RTFData: TWPRTFDataCollection; Reader: TWPCustomTextReader; const LoadPath, URL: String; TextObject: TWPTextObj; var Ok: Boolean); var stream : TMemoryStream; loadurl : string; begin if pos('http:',lowercase(URL))>0 then loadurl := URL else loadurl := LoadPath + URL;
stream := TMemoryStream.Create; try Panel2.Caption := URL; try Application.ProcessMessages; // this example uses INDY IdHTTP1.Get(loadurl,stream); except on e : Exception do Panel2.Caption := URL + '-->' + e.Message; end; if stream.Size>0 then try TextObject.LoadObjFromStream(URL,stream); except on e : Exception do Panel2.Caption := URL + '-->' + e.Message; end; ok := TRUE; if ok then Panel2.Caption := ''; Application.ProcessMessages; finally stream.Free; end; end;
|