将jpg图像放在word doc中并调整其大小

时间:2014-11-17 15:38:35

标签: java docx4j

我想知道你是否有任何关于在word doc中调整图像大小的想法,我正在使用docx4j。我有图像显示,但它太大了,我已经尝试了一切来调整它的大小。我已经尝试使用ImageWriter / ImageWriteParam param和SaveAsJPEGTiles方法进行压缩而运气不佳。它或者只是没有显示在单词doc中,或者它仍然太大。我真的需要它.5“X.5”。我永远不知道要放宽度和高度。 谢谢。

1 个答案:

答案 0 :(得分: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
相关问题