Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


hw wrote:

Hi,

so far, I have had no success whatsoever with including images into 
spreadsheets, texts or reports.

Such images either reside in a directory on a server and are accessible 
via a samba share and http, or they are generated on the fly and 
accessible via http.

Putting a hyperlink into a spreadsheet displays the hyperlink rather 
than the image.  Inserting a frame into a text document and assigning a 
hyperlink to the frame in order to have the image displayed within the 
frame displays nothing but the empty frame.

There doesn't seem to be any way at all to display images in a report.

Is it entirely impossible to integrate images?


Currently, I need to display EAN-13 barcodes in a document created via 
mail merge from data in a spreadsheet.  Since the barcode extension for 
LO does not work, I resorted to creating the barcodes on the web server. 
  But there is no way to have them displayed with LO.

If it's possible to include images, I need LO to query the web server 
with an EAN number so that the web server can create the corresponding 
barcode and insert it into the document created via mail merge.  The 
correct URL to retreive the barcode could be created within the spreadsheet.

How would I do this?

Do you want to do it programmatically? For example with a macro?

Here is some code I wrote to insert an image in a spreadsheet. The image may come from a local file 
or a URL on the web. The important thing to get the image embedded in the document rather than 
linked is to put it in the BitmapTable.

It creates a new document, but of course you can also do it in an existing document.

The code is in Python. Translate it to your favorite programmaing language if you want. You may 
have to set up the contexxt to run it in. If you want Basic code then search for the 'AndrewMacro' 
document where I got some of the code from.


def rundemo(Desktop, ServiceManager):
    calcdoc = Desktop.loadComponentFromURL("private:factory/scalc", "_blank", 0, ())
    sheets = calcdoc.getSheets()
    sheet1 = sheets.getByName("Sheet1")
    cell = sheet1.getCellByPosition(4, 5) # E6
    drawpage = calcdoc.DrawPages.getByIndex(0)
    image = calcdoc.createInstance("com.sun.star.drawing.GraphicObjectShape")
    drawpage.add(image)

    bitmaptable = calcdoc.createInstance("com.sun.star.drawing.BitmapTable")
        # You can also use a URL in the next line.
    bitmaptable.insertByName( "pic1", 'file:///Users/piet/TEST/picture.png')
    newURL = bitmaptable.getByName("pic1")
    image.GraphicURL = newURL
    image.Anchor = cell
    image.Position = cell.Position

    print(image.Graphic.Size100thMM)
    print(image.Graphic.SizePixel)
    
        # You can try to guess the size from Size100thMM or SizePixel if they are defined.
    image.Size = Size(1200, 400) 

-- 
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]

-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.