incubator-odf-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dimitrios Kateros <dkate...@gmail.com>
Subject Re: adding in memory image to document table cell
Date Tue, 11 Dec 2012 12:56:24 GMT
OK, made some progress. The following snippet will add the image to the
document package, but I still cannot add it to the Table using the
org.odftoolkit.simple.table.Cell#setImage(URI uri) method (it still ends up
looking to the filesystem).

byte[] img; //assume this is the image.

TextDocument odt = TextDocument.newTextDocument();
OdfPackage pkg = odt.getPackage();
pkg.insert(new ByteArrayInputStream(img), "Pictures/test.jpg",
"image/jpeg");

It looks that I have to manipulate the XML to look like this:

<table:table-cell table:style-name="a860a14">
    <text:p>
        <draw:frame svg:height="0.672cm" svg:width="3.444cm"
text:anchor-type="paragraph">
            <draw:image xlink:href="Pictures/test.jpg"
xlink:type="simple"></draw:image>
        </draw:frame>
    </text:p>
</table:table-cell>

Is the advanced API my only bet right now?

Thx again // Dimitris

PS: I obviously do not have enough experience with the library (just today
tbh), but, if there is no other way to do it with the simple API, would it
be too far-fetched for the implementation to handle it correctly if the
relative odf package path is used as the URI input?



On Tue, Dec 11, 2012 at 12:54 PM, Dimitrios Kateros <dkateros@gmail.com>wrote:

> Greetings,
>
> I have an in memory image that I wish to add to a specific table cell of a
> document.
>
> As far as I can tell, the OdfToolkit API only allows this if the user
> provides a java.net.URI instance.
>
> Is there anyway to circumvent this using either the simple or the dom api?
> I would prefer not to write the image to disk (or anything similar) in
> order to provide a URI.
>
> Thank you in advance,
>
> Dimitris
>



-- 
Dimitrios Kateros

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message