Page 1 of 1

Adding an image to an existing document

PostPosted: Thu May 23, 2013 6:32 am
by jmjatlanta
Firstly, thank you for all of your work. I know this stuff is not easy.

I am playing with the library, and attempting to add a jpeg image to an existing Word document within Android.

org.docx4j.openpackaging.parts.WordprocessingML.BindaryPartAbstractImage seems to be the heart of the problem I am having, as it was constructing a DefaultImageContext that seemed to need the AWT. My solution was to make my own DefaultImageContext that eliminated the "if" statement in the original's constructor, and sets the private sourceResolution to GraphicsConstraints.DEFAULT_DPI. Good solution?

Of course, other problems arose around the use of sun's java2d stuff when trying to get the ImageInfo. I think the objective is to get the correct MIME type and size of the image from an array of bytes. I've considered rewriting these areas using android libraries, kind of like this existing code: http://www.java2s.com/Code/Android/2D-G ... egSize.htm

Do you believe this to be a good approach? Is there an easier path? Should I instead attempt to bring in the necessary java2d classes? Any help would be appreciated.

Re: Adding an image to an existing document

PostPosted: Thu May 23, 2013 10:52 pm
by jason
Its been a while since I looked at the android stuff....

Are you using our re=packaged AWT from https://github.com/plutext/AndroidDocxT ... ae-awt.jar

https://github.com/plutext/docx4j/blob/ ... Image.java uses that.

Presumably https://github.com/plutext/AndroidDocxT ... ommons.jar does as well.

Otherwise, can you generate a stack trace which shows where awt is being used?

Re: Adding an image to an existing document

PostPosted: Fri Sep 05, 2014 9:07 am
by drew.coleman
I am having this same problem. When I add the awt jar included with the Android demo, I end up hitting the method count limit for the dex files.

Is there a way to fix this or go around it?