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

Empty output file running extract example on a test pdf file #50

Open
bogct0mculhl opened this issue Feb 13, 2023 · 2 comments
Open

Empty output file running extract example on a test pdf file #50

bogct0mculhl opened this issue Feb 13, 2023 · 2 comments

Comments

@bogct0mculhl
Copy link

Hi, I'm trying to understand how to use your library, but I'm not able to run your example code corrrectly:

git clone https://github.com/jrmuizel/pdf-extract.git

cd pdf-extract

wget https://orimi.com/pdf-test.pdf

cargo run --example extract pdf-test.pdf

The output file is empty...

cat pdf-test.txt

Using pdftotext the output file is filled with text:

pdftotext -layout pdf-test.pdf

cat pdf-test.txt

PDF Test File

Congratulations, your computer is equipped with a PDF (Portable Document Format)
reader! You should be able to view any of the PDF documents and forms available on
our site. PDF forms are indicated by these icons:   or  .

Yukon Department of Education
Box 2703
Whitehorse,Yukon
Canada
Y1A 2C6

Please visit our website at: http://www.education.gov.yk.ca/

Thanks

@joepio
Copy link
Contributor

joepio commented Feb 19, 2023

Hi @bogct0mculhl! Do you want to use the code as a library or as a CLI executable? If you want to use it as a library, the easiest way to do so is probably this:

let bytes = std::fs::read("path/to/example.pdf").unwrap();
let out = pdf_extract::extract_text_from_mem(&bytes);
assert!(out.contains("Yukon Department of Education"));

@jrmuizel
Copy link
Owner

That pdf is encrypted which is not currently supported. J-F-Liu/lopdf#168

The extract example will now output a warning about it. 277fe7c

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

3 participants