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

Open a include images docx file. Then save it. All images disappeared. #717

Open
zemelLeong opened this issue May 20, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@zemelLeong
Copy link

zemelLeong commented May 20, 2024

I use this code read this file got the issue.

impl Template {
    pub fn new(path: String) -> errors::Result<Self> {
        let path = PathBuf::from(path);

        let mut buf: Vec<u8> = Vec::new();
        File::open(path)?.read_to_end(&mut buf)?;

        let docx = docx_rs::read_docx(&buf)?;

        Ok(Self { docx })
    }

    pub fn save(self, path: &str) {
        let path = std::path::Path::new(path);
        let file = std::fs::File::create(path).unwrap();

        self.docx.build().pack(file).unwrap();
    }
}

Template::new(path)?.save("./xxx.docx")

screenshot

The 无法显示该图片 means cannot show this image.
image

@zemelLeong zemelLeong added the bug Something isn't working label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant