Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i insert img into docx file, office can't open this file #592

Open
yang-xinfu opened this issue Sep 5, 2024 · 0 comments
Open

i insert img into docx file, office can't open this file #592

yang-xinfu opened this issue Sep 5, 2024 · 0 comments

Comments

@yang-xinfu
Copy link

docx4j version: 8.3.11
office version: 16.50

when i insert img into docx file, use office 2019 can't open this file

insert img demo:

BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordMLPackage, imageFile);
Inline inline = imagePart.createImageInline(UUID.randomUUID().toString(), "", l, l2, widthEmu, heightEmu, false);
drawing = RunUtils.getObjectFactory().createDrawing();
drawing.getAnchorOrInline().add(inline);

i get document.xml like :

<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"
            xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
            xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"
            xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
            xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
...
<w:drawing>
                    <wp:inline distT="0" distB="0" distL="0" distR="0">
                        <wp:extent cx="1104900" cy="869330"/>
                        <wp:effectExtent l="0" t="0" r="0" b="0"/>
                        <wp:docPr id="7723563636378128964" name="d00d3752-492e-4abb-bbe7-cb74cfe8ea1a" descr=""/>
                        <wp:cNvGraphicFramePr>
                            <a:graphicFrameLocks noChangeAspect="true"/>
                        </wp:cNvGraphicFramePr>
                        <a:graphic>
                            <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
                                <pic:pic>
                                    <pic:nvPicPr>
                               ...
                </w:drawing>

and,i use office word create a new file,and manually insert pictures, i find document.xml like:

<a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
<a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
<pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
....

at last,i manually modify docx4j created docx file like above ,and it can be open by office。

What can I do to make it get good result?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant