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

Please tell me how to remove the PNG file from the PDF file. #235

Open
abskihDDloh opened this issue Sep 22, 2024 · 1 comment
Open

Please tell me how to remove the PNG file from the PDF file. #235

abskihDDloh opened this issue Sep 22, 2024 · 1 comment

Comments

@abskihDDloh
Copy link

Hello,

I am currently working on a project in Rust to extract images from PDF files. I have successfully used the pdf crate to extract JPEG images from PDFs, but I am unsure how to extract PNG images.

Specifically, I am able to extract JPEG images with the following code, but I would like to know how to modify it to extract PNG images instead:
https://github.com/abskihDDloh/pdf_to_image_rs

If I add the contents as shown in src/get_image_from_pdf.rs (Near line 253.) , I will get a binary file that is not recognized as an image.

Before:

        let ext = match filter {
            Some(StreamFilter::DCTDecode(_)) => "jpg",
            Some(StreamFilter::JBIG2Decode(_)) => "jbig2",
            Some(StreamFilter::JPXDecode) => "jp2k",

After:

        let ext = match filter {
            Some(StreamFilter::DCTDecode(_)) => "jpg",
            Some(StreamFilter::JBIG2Decode(_)) => "jbig2",
            Some(StreamFilter::JPXDecode) => "jp2k",
            Some(StreamFilter::FlateDecode(_)) => "png",

Could someone please advise on how to extract PNG images from a PDF using the pdf crate?

Thank you for your help.

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

4 participants
@abskihDDloh and others