-1

I'm wondering if you had any ideas about resizing an image in word doc, I'm using docx4j. I've got the image showing but it is too big and I've tried everything to resize it. I've tried compressing with ImageWriter/ImageWriteParam param and the method SaveAsJPEGTiles with not much luck. It either just doesn't show up in the word doc or it is still too large. I really need it to be .5"X.5". I never know what to put in for the width and height. Thank you.

Dkeane
  • 31
  • 6

1 Answers1

1

Use the cx parameter to set the width!

/**
 * Create a <wp:inline> element suitable for this image,
 * which can be _embedded_ in w:p/w:r/w:drawing.
 * @param filenameHint Any text, for example the original filename
 * @param altText  Like HTML's alt text
 * @param id1   An id unique in the document
 * @param id2   Another id unique in the document
 * @param cx    Image width in twip
 * @param link  true if this is to be linked not embedded
 * None of these things seem to be exposed in Word 2007's
 * user interface, but Word won't open the document if 
 * any of the attributes these go in (except @ desc) aren't present!
 * @throws Exception
 */
public Inline createImageInline(String filenameHint, String altText, 
        int id1, int id2, long cx, boolean link) throws Exception
Vlad
  • 10,602
  • 2
  • 36
  • 38
  • Thanks so much! That worked! I knew it would be a simple thing in the end :) It always seems to be. – Dkeane Nov 18 '14 at 17:55
  • @Dkeane Glad to help! You don't have to thank me, upvoting/accepting the answer lets everyone know it solves the problem and was useful. – Vlad Nov 18 '14 at 18:38