Hi guys,
I need help for convert docx to msg(the format of OUTLOOK).and i want to see if DOCX4J is available to do it? How to do? or which API can deal with it?
Thank for your help.
It is currently Tue Oct 14, 2025 5:44 pm
My Colleague wrote:Hi,
I'm new with docx4j and OpenDoPE. I've created a word document that I use as template.
So I'm binding some parts of that document with ...
String bookmarkStart =
"<w:bookmarkStart w:id=\"0\" w:name=\"sampleBookmark\" />",
bookmarkEnd = "<w:bookmarkEnd w:id=\"0\" />";
Object bStart = XmlUtils.unmarshalString(bookmarkStart);
Object bEnd = XmlUtils.unmarshalString(bookmarkEnd);
The prefix "w" for element "w:bookmarkStart" is not bound.
List<DefaultElement> elementList = documentSettings.getDocument().getRootElement().elements();
for(DefaultElement e:elementList){
if(e.getName().equals("documentProtection")) {
List<DefaultAttribute> attributeList = e.attributes();
for(DefaultAttribute a:attributeList) {
if(a.getName().equals("edit")) {
if(a.getValue().equals("comments")) protectType = STDocProtect.COMMENTS;
if(a.getValue().equals("forms")) protectType = STDocProtect.FORMS;
if(a.getValue().equals("none")) protectType = STDocProtect.NONE;
if(a.getValue().equals("readOnly")) protectType = STDocProtect.READ_ONLY;
if(a.getValue().equals("trackedChanges")) protectType = STDocProtect.TRACKED_CHANGES;
}
}
}
}
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(_package, bytes);
Inline inline = imagePart.createImageInline(null, null, id1, id2, false);
// Now wrap the inline in w:p/w:r/w:drawing
P p = _objFactory.createP();
R run = _objFactory.createR();
p.getParagraphContent().add(run);
org.docx4j.wml.Drawing drawing = _objFactory.createDrawing();
run.getRunContent().add(drawing);
drawing.getAnchorOrInline().add(inline);
_documentPart.addObject(p);
rel.setTargetMode("External");
Total posts 10200 • Total topics 2872 • Total members 2100