use pdfluent::prelude::*;
use std::path::PathBuf;
fn out_path() -> PathBuf {
std::env::temp_dir().join("pdfluent-bootstrap-encrypted.pdf")
}
pub fn run_to(out: &std::path::Path) -> Result<()> {
let mut doc = PdfDocument::open_with(
"tests/fixtures/sample.pdf",
pdfluent::OpenOptions::new().with_license_key("tier:team"),
)?;
doc.encrypt(
EncryptOptions::aes256()
.with_user_password("user-secret")
.with_owner_password("owner-secret")
.with_permissions(Permissions::print_only()),
)?;
doc.save(out)?;
Ok(())
}
pub fn run() -> Result<()> {
run_to(&out_path())
}
#[test]
fn encrypt_pdf_rust_runs() {
let path = out_path();
let _ = std::fs::remove_file(&path);
run_to(&path).expect("encrypt flow");
let _ = std::fs::remove_file(&path);
}
#[test]
fn encrypt_pdf_rust_compiles() {
let _f: fn() -> Result<()> = run;
}