use lopdf::Document;
#[cfg(not(feature = "async"))]
fn main() {
let args: Vec<String> = std::env::args().collect();
assert!(args.len() >= 3, "Not enough arguments: input_file output_file <password>");
let input_file = &args[1];
let output_file = &args[2];
let password = if args.len() >= 4 { &args[3] } else { "" };
let mut doc = Document::load(input_file).unwrap();
if doc.encryption_state.is_none() && !doc.is_encrypted() {
println!("nothing to be done");
return;
}
if doc.is_encrypted() {
doc.decrypt(password).unwrap();
}
doc.save(output_file).unwrap();
}
#[cfg(feature = "async")]
#[tokio::main]
async fn main() {
let args: Vec<String> = std::env::args().collect();
assert!(args.len() >= 3, "Not enough arguments: input_file output_file <password>");
let input_file = &args[1];
let output_file = &args[2];
let password = if args.len() >= 4 { &args[3] } else { "" };
let mut doc = Document::load(input_file).await.unwrap();
if doc.encryption_state.is_none() && !doc.is_encrypted() {
println!("nothing to be done");
return;
}
if doc.is_encrypted() {
doc.decrypt(password).unwrap();
}
doc.save(output_file).unwrap();
}