Useful for pre-flight checks, compatibility filtering, and document auditing pipelines.
use pdfluent::PdfDocument;
fn main() -> pdfluent::Result<()> {
let doc = PdfDocument::open("file.pdf")?;
let v = doc.version();
println!("PDF {}.{}", v.major, v.minor);
Ok(())
}The base crate includes all document metadata and version inspection functions.
# Cargo.toml
[dependencies]
pdfluent = "1.0.0-beta.8"pdf_version() reads the %PDF-x.y header from the first 8 bytes of the file. It does not require full document parsing.
use pdfluent::PdfDocument;
let doc = PdfDocument::open("document.pdf")?;
let version = doc.version();
println!("{}.{}", version.major, version.minor);Use predefined constants to write readable version checks. PdfVersion implements PartialOrd.
let v = doc.version();
match (v.major, v.minor) {
(1, 0) => println!("Very old document"),
(1, 4) => println!("PDF 1.4 - supports transparency"),
(1, 5) => println!("PDF 1.5 - supports object streams"),
(1, 6) => println!("PDF 1.6 - supports AES-128"),
(1, 7) => println!("PDF 1.7 - supports AES-256"),
(2, 0) => println!("PDF 2.0 - latest standard"),
_ => println!("Other version: {}.{}", v.major, v.minor),
}Use PdfDocument::peek_version() to read only the header bytes. This is faster when you need to filter files before loading them.
use pdfluent::PdfDocument;
let doc = PdfDocument::open("document.pdf")?;
let version = doc.version();
println!("PDF {}.{}", version.major, version.minor);
// Only proceed for documents that are at least PDF 1.6
if (version.major, version.minor) >= (1, 6) {
// ...
}No JVM, no runtime, no DLL dependencies. Ships as a single native binary or WASM module.
Rust's ownership model prevents buffer overflows and use-after-free. No segfaults in PDF parsing.
Same code runs server-side, in Docker, on AWS Lambda, on Cloudflare Workers, or in the browser via WASM.