michel
|
Posted: December 21, 2009 16:59 by michel
|
|
Hello, im stuck at creating an image and using it in an odt document. I'm using the toolkit to fill a template. I tried something like this:
OdfDrawImage image = odfDom.newOdfElement(OdfDrawImage.class);
image.newImage(new URI("image.jpg"));
odfElement.appendChild(image);
What am i doing wrong? Thanks in advance. |
How to create an image
101 topics, 268 posts
» Share this
Replies: 2 - Last Post: January 09, 2010 14:56
by: michel
by: michel
showing 1 - 3 of 3
Svante Schubert
|
Posted: December 22, 2009 11:15 by Svante Schubert
|
|
Hi Michel, I assume you are missing some of the ODF attributes on the image elements (ie. draw:frame or draw:image) that your ODF application requires. At least I had once the similar problem with OpenOffice. We (in ODFDOM) are currently prototyping with an ODF reference that should provide the substantial information, but we are not yet so far: http://odftoolkit.org/downloads/odfdom/OpenDocument-v1.2-draft/OdfReference.html#element_draw:frame_0 The easy way that solves your problem is not to work on the ODFDOM DOM API, but use the ODFDOM Convenient API build ontop of the DOM API. The Convenient API will cover all unnecessary ODF XML implementation detail and will give a rich usability. Take a look at org.odftoolkit.odfdom.doc.draw.OdfDrawImage esp. public String newImage(URI imageUri) and public void newImage(InputStream is, String packagePath, String mediaType) The Convenient API is the last piece of our architecture, similar to the roof of an house. Although OdfDrawImage is an exception an exists there are wide gaps yet and you will need to work on the DOM API from time to time. In the end there will be a feature tree similar to the DOM tree, where you might have the newImage method directly on the feature root, eg. the OdfTextDocument as office:text has draw:frame as child, see http://odftoolkit.org/downloads/odfdom/OpenDocument-v1.2-draft/OdfReference.html#element_office:text_0 The pragmatic way to solve future similar DOM problems you might run into is to take a look into the XML from an ODF application (e.g. OpenOffice) and see what attributes exist by default. Nevertheless we are working on an improvement of the reference and Convenient API in ODFDOM and would welcome you gladly if you might assist us in one or the other improvement. Hope that helps you, Svante |
michel
|
Posted: January 09, 2010 14:56 by michel
|
|
Hi Svante, i just came back from holidays. Thank you very much for your post. This really helped me to understand what the problem was. Your suggestion worked ![]() Looking into the xml files helped me to unterstand other problems (like leftovers after deleting elements) i ran into. Maybe i can look into the code of ODFDOM in the semester break. Your post helped me a lot. Thanks again, Michel |
Replies: 2 - Last Post: January 09, 2010 14:56
by: michel
by: michel




