J-F-Liu / lopdf

A Rust library for PDF document manipulation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot decode LZWDecode

RazrFalcon opened this issue · comments

Here is TIFF 6 spec which uses LZWDecode: https://web.archive.org/web/20180810205359/https://www.adobe.io/content/udp/en/open/standards/TIFF/_jcr_content/contentbody/download/file.res/TIFF6.pdf

Stream::decompress_lzw fails with:

Custom { kind: InvalidData, error: "InvalidCode" }

I'm not sure if this is weezl error or lopdf, because older lzw version of lopdf fails too.

the following code I ran using the TIFF6.pdf

fn get_mut() -> Result<bool> {
    let mut doc = Document::load("assets/TIFF6.pdf")?;
    doc.save("assets/TIFF_saved.pdf")?;
    Ok(true)
}

It loaded the document successfully and saved it to without Error. So I suspect it was a weezl bug and this can be closed @J-F-Liu @RazrFalcon

lopdf simply ignores weezl errors:

warn!("{}", err);

can you show me how your loading the file to run into this issue?

I'm not "loading" it, I was just testing this crate and saw a warning in the log.