gpt4 book ai didi

java - 内容控制图片绑定(bind)

转载 作者:行者123 更新时间:2023-12-01 14:21:20 24 4
gpt4 key购买 nike

感谢这个excellent sample ,我现在熟悉使用 docx4j 在运行时将值从任何构建良好的 xml 文件绑定(bind)到包含内容控件的 Word 模板。但我找不到一种方法来实现在模板中注入(inject)图片的类似效果。

我尝试使用 Word 开发人员功能区在模板中添加图片内容控件,并将其绑定(bind)到 xml 输入中的一个值,该值是图片的 64 位编码字符串。但是当我使用 docx4j 执行绑定(bind)时,生成的 doc 文件不包含图片,而是得到一个奇怪的结果(请参阅捕获)。

我的绑定(bind)方法如下所示:

// Process conditionals and repeats
OpenDoPEHandler odh = new OpenDoPEHandler(_document);
odh.preprocess();

OpenDoPEIntegrity odi = new OpenDoPEIntegrity();
odi.process(_document);

// Apply the bindings
// Convert hyperlinks, using this style
BindingHandler.setHyperlinkStyle("Hyperlink");
BindingHandler.applyBindings(_document);

// Strip content controls: you MUST do this
// if you are processing hyperlinks
RemovalHandler rh = new RemovalHandler();
rh.removeSDTs(_document, Quantifier.ALL);

保存.docx结果后的结果:

enter image description here

我错过了什么吗?我可以在某个地方找到正确执行此操作的示例吗?

感谢您的帮助!CL

PS:我创建了an equivalent post在 docx4j 论坛上:如果在那里找到可行的解决方案,我会在这里报告。

最佳答案

该图像是嵌入到 picture-bind.docx 中的图像,通过:

    <w:dataBinding w:xpath="/invoice[1]/items[1]/item[1]/name[1]" w:storeItemID="{3C1B665A-D738-4822-8EFB-14B133235CCB}"/>

您没有成功更改该绑定(bind)。

出于 docx4j/OpenDoPE 的目的,我建议您使用 authoring add-in创建您的内容控件。如果该工具检测到您正在绑定(bind) Base64 编码的图像,它将自动创建一个图片内容控件。

关于java - 内容控制图片绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17531594/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com