2014-11-17 66 views
-1

我想知道如果您对word文档中的图像调整大小有任何想法,我正在使用docx4j。我已经看到了图像,但它太大了,我已经尝试了一切来调整它的大小。我试过压缩与ImageWriter/ImageWriteParam参数和方法SaveAsJPEGTiles没有太多的运气。它或者不在文档doc中显示,或者它仍然太大。我真的需要它是.5“X.5”。我从来不知道要在宽度和高度上投入什么。 谢谢。将JPG图像放入word文档并调整其大小

回答

1

使用cx参数设置宽度!

/** 
* 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 
+0

非常感谢!这工作!我知道这将是一件简单的事情:)它似乎总是。 – Dkeane

+0

@Dkeane很高兴帮助!您不必感谢我,upvoting /接受答案让大家知道它解决了这个问题,并且很有用。 – Vlad

相关问题