首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android Docx4j图像错误

Android Docx4j图像错误
EN

Stack Overflow用户
提问于 2016-02-03 19:29:45
回答 2查看 250关注 0票数 1

我试图创建一个word文档并将其填充到一个数据库中。我正在使用Docx4j。在安卓系统上。没有图片,代码运行良好,但是对于图像,它会崩溃。

这里是它崩溃的地方:

代码语言:javascript
复制
private static void addImageToPackage(Tc tableCell,
                                      byte[] bytes) throws Exception {
    BinaryPartAbstractImage imagePart =
            BinaryPartAbstractImage.createImagePart(wordMLPackage, bytes);

    int docPrId = 1;
    int cNvPrId = 2;
    Inline inline = imagePart.createImageInline("Filename hint",
            "Alternative text", docPrId, cNvPrId, 500000, 500000, false);

    P paragraph = addInlineImageToParagraph(inline);
    PPr paragraphProperties = factory.createPPr();
    Jc justification = factory.createJc();
    justification.setVal(JcEnumeration.RIGHT);
    paragraphProperties.setJc(justification);
    paragraph.setPPr(paragraphProperties);
    tableCell.getContent().add(paragraph);
}

更新:没有任何错误的代码。我的问题是Docx4j有问题--库和Android在BinaryPartAbstractImage.java上有一些问题。奥古斯丁·西沃普拉斯的回答帮助了我。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-02-03 20:30:42

看来罐子有问题了。过去,我曾与docx4j和安卓发生过一场激烈的斗争。

这是带有jars的libs文件夹。为我工作。

OSSkWMkOEAEMvhLN-t/view?usp=sharing

票数 0
EN

Stack Overflow用户

发布于 2018-10-06 02:18:26

尝试更改docx4j的版本。对我起作用了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35185975

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档