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

read_docx does not parse image? #617

Open
jymchng opened this issue Apr 15, 2023 · 0 comments
Open

read_docx does not parse image? #617

jymchng opened this issue Apr 15, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@jymchng
Copy link

jymchng commented Apr 15, 2023

Describe the bug

docx_rs::read_docx reading a .docx file with images should return Docx struct with non-empty RunChild::Drawing variant with Drawing.Pic.image to be a non-empty vector but it doesn't.

Reproduced step

Steps to reproduce the behavior:

fn read_to_vec(file_name: &PathBuf) -> anyhow::Result<Vec<u8>> {
    let mut buf: Vec<u8> = Vec::new();
    std::fs::File::open(file_name)?.read_to_end(&mut buf)?;
    Ok(buf)
}

let mut original_docx = docx_rs::read_docx(&read_to_vec(&path)?)?;
dbg!(&original_docx);

Expected behavior

The dbg!(&original_docx); should print out something that indicates that RunChild::Drawing variant with Drawing.Pic.image is a non-empty vector.

Actual behavior

Instead, it prints out this:

children: [
                                    Drawing(
                                        Drawing {
                                            data: Some(
                                                Pic(
                                                    Pic {
                                                        id: "rId5",
                                                        image: [],
                                                        size: (
                                                            679639,
                                                            679639,
                                                        ),
                                                        position_type: Inline,
                                                        simple_pos: false,
                                                        simple_pos_x: 0,
                                                        simple_pos_y: 0,
                                                        layout_in_cell: true,
                                                        relative_height: 0,
                                                        allow_overlap: true,
                                                        position_h: Offset(
                                                            0,
                                                        ),
                                                        position_v: Offset(
                                                            0,
                                                        ),
                                                        relative_from_h: Margin,
                                                        relative_from_v: Margin,
                                                        dist_t: 0,
                                                        dist_b: 0,
                                                        dist_l: 0,
                                                        dist_r: 0,
                                                        rot: 0,
                                                    },
                                                ),
                                            ),
                                        },
                                    ),
                                ]

This indicates that indeed, the images are not read.

Screenshots

Screenshot of original .docx file
image

Desktop (please complete the following information)

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]
@jymchng jymchng added the bug Something isn't working label Apr 15, 2023
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