Add picture to paragraph with wrap

Questions and answers on how to use DOCXReadWrite
Post Reply
nalanfeng
Posts: 16
Joined: Fri Dec 25, 2020 12:49 pm

Add picture to paragraph with wrap

Post by nalanfeng »

Hi,
I have the following problem with adding picture to paragraph. When I insert some text and pictures into the paragraph, I want the picture to follow the text, that is, "In line with text", so I set the "wrap" value to agowInLine, but it doesn't seem to work properly. I looked at the "text wrapping" of the picture and found it is "Behind text". Maybe I'm doing something wrong, code show as below:

Code: Select all

var
  GrPic: TAXWGraphicPicture;
  Pic: TAXWPicture;
  Para: TAXWLogPara;
  DOCX: TDOCXReadWrite;
begin
  ... 
  Para := DOCX.Editor.Paras.AppendPara;
  Pic  := DOCX.Editor.Pictures.AddPicture('123.jpg');
  GrPic := TAXWGraphicPicture.Create(Pic);
  GrPic.Wrap := agowInLine;
  GrPic.Scale(0.5);
  Para.AddGraphic(GrPic);
  
  Para := DOCX.Editor.Paras.AppendPara;
  Para.AppendPlainText('Embarcadero Studio');
  
  Para := DOCX.Editor.Paras.AppendPara;
  Para.AppendPlainText('TAXWReadWriteVCL');
end; 
Image

Thanks!
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: Add picture to paragraph with wrap

Post by larsa »

Hello

You must use AppendPicture when you want a picture inline. Example:

Code: Select all

  Para := DOCX.Editor.Paras.AppendPara;
  Para.AppendPlainText('TAXWReadWriteVCL');
  Para.AppendPicture('123'jpg')
Lars Arvidsson, Axolot Data
nalanfeng
Posts: 16
Joined: Fri Dec 25, 2020 12:49 pm

Re: Add picture to paragraph with wrap

Post by nalanfeng »

Using AppendPicture,this works perfectly.Thank you
Post Reply