Please tell me how to remove the PNG file from the PDF file.
Opened this issue · 0 comments
abskihDDloh commented
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.