lopdf icon indicating copy to clipboard operation
lopdf copied to clipboard

Cannot decode LZWDecode

Open RazrFalcon opened this issue 1 year ago • 4 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.

RazrFalcon avatar Jul 20 '22 15:07 RazrFalcon

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

genusistimelord avatar Aug 02 '22 13:08 genusistimelord

lopdf simply ignores weezl errors:

https://github.com/J-F-Liu/lopdf/blob/6b04581640e061bfeb39b585e50a7e9d102b8fe2/src/object.rs#L604

RazrFalcon avatar Aug 02 '22 13:08 RazrFalcon

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

genusistimelord avatar Aug 02 '22 14:08 genusistimelord

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

RazrFalcon avatar Aug 02 '22 14:08 RazrFalcon