Page 1 of 1

Insert Pictures with internal link

PostPosted: Thu Nov 14, 2013 2:39 pm
by beranger
hi,

i've a problem when i use pyUNO in order to insert pictures. I'm using that code :
Code: Select all   Expand viewCollapse view
graphic = doc.createInstance( "com.sun.star.text.TextGraphicObject" )
   text.insertTextContent(cursor, graphic, True )                  
   
   graphic.AnchorType = "AT_PARAGRAPH"
   print file_name_template_run
   graphic.GraphicURL = "file://"+file_name_template_run#"/home/beranger/Images/Diagramme_Taylor.png"
   graphic.SurroundAnchorOnly = True

   graphic.TopMargin = 5
   graphic.BottomMargin = 5

   print ("page Orientation=default")
   text.insertControlCharacter(cursor, PARAGRAPH_BREAK, False)
   print ("legende:",legende)
   graphic.Width = graphic.Width / 1.5
   graphic.Height = graphic.Height / 1.5
   graphic.Name=legende               
   cursor = setProperty(cursor,20,"Arial",150,"Caption")
   text.insertString(cursor, legende, False )
   text.insertControlCharacter(cursor, PARAGRAPH_BREAK, False)
   cursor = setProperty(cursor,20,"Arial",150,"Text body")


but the problem is that when i send my document by email , pictures doesn't appear because i've create an external link, document can't find pictures file's in an other computer.
Did anyone have a solution in order to create an internal link for pictures?

i've find some example but impossible to compute them in my code..

thanks,

it's ok for me,
Code: Select all   Expand viewCollapse view
   graphic = doc2.createInstance( "com.sun.star.text.TextGraphicObject" )
   text2.insertTextContent(cursor2, graphic, True )
   graphic.GraphicURL = "file://"+file_name_template_run
   graphic.Width = graphic.Width / 1.5
   graphic.Height = graphic.Height / 1.5
   GraphW=graphic.Width
   GraphH=graphic.Height
   text2.removeTextContent(graphic)
   
   DrawPage=doc.getDrawPage()
   Url="file://"+file_name_template_run

   LoadUrl = LoadGraphicIntoDocument( doc, Url, legende )
   #oShape = doc.createInstance( "com.sun.star.drawing.GraphicObjectShape" )
   oShape = doc.createInstance( "com.sun.star.text.TextGraphicObject" )
   text.insertTextContent(cursor, oShape, False )      
   #DrawPage.add(oShape)
   oShape.GraphicURL = LoadUrl
   oShape.AnchorType = "AT_PARAGRAPH"
   oShape.SurroundAnchorOnly = True
   oShape.TopMargin = 5
   oShape.BottomMargin = 5
   oShape.Width =GraphW
   oShape.Height = GraphH