Inserting Graphics in a Writer document

Piet van Oostrum piet at vanoostrum.org
Wed Apr 15 09:50:40 PDT 2015


Niklas Johansson wrote:

 > If I were you I would set the Anchor before I insert the image into the 
 > document. So change the order of these lines:
 > 
 >      xText.insertTextContent(cursor, oGraphic, False)
 >      # Setting the anchor type - must be done first, otherwise the graphic will be put after the //
 >      oGraphic.AnchorType = AS_CHARACTER

YES!! That solves it. Thans a lot.

 > Once the image is inserted into the document you won't always be able to 
 > change the anchor as you try to do in the code above. For some reason it 
 > works in your first example but as you can see it won't work in your 
 > second example.

I did is as it was done in the Java code.

 > So remember to always change the anchor of the graphic before you insert 
 > it otherwise you'll get more of these nice surprises. If I remember 
 > correctly there are a few more settings that should be done to the 
 > graphic object before it's inserted and some that needs to be set after, 
 > but I don't remember the details at the moment.

I hope that these things are documented somewhere.

 > It seems that what is happening in the second case is that the image 
 > gets inserted before the anchor-change and when the re-anchoring occurs 
 > the image is already in the wrong position.
 > 
-- 
Piet van Oostrum <piet at vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]


More information about the LibreOffice mailing list