Skip to content

Commit

Permalink
hide behind flag
Browse files Browse the repository at this point in the history
  • Loading branch information
saraswatpuneet committed Jul 24, 2024
1 parent dfb6195 commit 4be93f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2508,6 +2508,7 @@ pub fn print_metadata(doc: &Document) {
);
}

#[cfg(not(feature="async"))]
/// Extract the text from a pdf at `path` and return a `String` with the results
pub fn extract_text<P: std::convert::AsRef<std::path::Path>>(
path: P,
Expand Down Expand Up @@ -2538,6 +2539,7 @@ fn maybe_decrypt(doc: &mut Document) -> Result<(), OutputError> {
Ok(())
}

#[cfg(not(feature="async"))]
pub fn extract_text_encrypted<P: std::convert::AsRef<std::path::Path>, PW: AsRef<[u8]>>(
path: P,
password: PW,
Expand Down
21 changes: 12 additions & 9 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,17 @@ impl ExpectedText<'_> {
} else {
format!("tests/docs/{}", filename)
};
let out = extract_text(file_path)
.unwrap_or_else(|e| panic!("Failed to extract text from {}, {}", filename, e));
println!("{}", out);
assert!(
out.contains(text),
"Text {} does not contain '{}'",
filename,
text
);
#[cfg(not(feature = "async"))]
{
let out = extract_text(file_path)
.unwrap_or_else(|e| panic!("Failed to extract text from {}, {}", filename, e));
println!("{}", out);
assert!(
out.contains(text),
"Text {} does not contain '{}'",
filename,
text
);
}
}
}

0 comments on commit 4be93f8

Please sign in to comment.