easypdf-core
Foundation layer for easypdf-rust: core traits, types, IO safety primitives, PDF crypto (encrypt/sign), and Markdown IR.
Role
easypdf-core is the lowest-level crate in the easypdf-rust workspace. It defines the shared abstractions that every upper-layer crate (reader, writer, markdown, ocr, runtime) depends on: core traits, content types, enums, error types, IO guards, encryption, digital signatures, and the semantic document model (PdfBlock / PdfDocumentModel).
Core Capabilities
- Core traits (
PdfModel,PdfReadListener,PdfWriteHandler,PdfConverter,PdfEngine) -- extension points for reading, writing, and conversion (crates/easypdf-core/src/traits.rs) - Content model (
PdfText,PdfTable,PdfImage,PdfLine,PdfRect) -- semantic content elements (crates/easypdf-core/src/content.rs) - Document IR (
PdfDocumentModel,PdfPageModel,PdfBlockwith 14 variants) -- structured intermediate representation (crates/easypdf-core/src/model/) - IO safety (
PdfInput,ResourceLimits,AtomicFileOutput,guard_decompression_bomb,guard_element_explosion) -- resource limits, SSRF protection, crash-safe writes (crates/easypdf-core/src/io/) - PDF encryption (AES-128/256, ISO 32000) --
encrypt_pdf()/decrypt_pdf()with 8 permission flags (crates/easypdf-core/src/crypto/encrypt.rs) - PDF signing (PKCS#7/CMS, RSA-PKCS#1v1.5 + SHA-256 via
ring) --sign_pdf()/verify_pdf_signature()(crates/easypdf-core/src/crypto/sign.rs) - Style & metadata (
PdfFont,PdfColor,BuiltInFont,TableStyle,PdfMetadata,PdfBookmark) -- (crates/easypdf-core/src/style.rs,crates/easypdf-core/src/metadata.rs) - Layout engine (
FlowLayout,LayoutSink,Direction) -- flow-based layout infrastructure (crates/easypdf-core/src/layout/)
Dependencies
Internal
None -- this is the foundation crate.
External
| Crate | Version | Purpose |
|---|---|---|
lopdf |
0.44.0 | PDF object model (encrypt/decrypt via lopdf API) |
ring |
0.17 | Constant-time RSA operations for signing |
aes / cbc / cipher |
-- | AES encryption primitives |
x509-parser |
0.16 | X.509 certificate parsing |
bitflags |
2 | PdfPermissions bitflags |
thiserror |
2.0.18 | Error type derivation |
chrono |
0.4.45 | Date/time handling |
serde / serde_json |
1.x | Serialization |
Main API
Enums
// Page & layout
// Content block (#[non_exhaustive], 14 variants)
// Crypto
Traits
Content Builders
let text = new
.font
.alignment
.color;
let table = new
.row
.width;
Encryption & Signing
use ;
let enc = new
.with_algorithm
.with_permissions;
let encrypted = encrypt_pdf?;
// Signing
use ;
sign_pdf?;
let info = verify_pdf_signature?;
IO Safety
let input = from_path;
let limits = default; // 50 MB, 10000 pages
let bytes = input.read?;
// Atomic writes
let out = new;
out.write_all?; // writes to temp, renames on success
Known Limitations
- RFC 3161 timestamp server support: fields reserved but not yet implemented (
crates/easypdf-core/src/crypto/sign.rs:69) PdfEnginetrait defined but no concrete implementation yet (crates/easypdf-core/src/traits.rs:260-263)unsafe_code = "forbid"enforced workspace-wide
License
Apache-2.0
Project: https://github.com/easy-4-rust/easypdf-rust crates.io: https://crates.io/crates/easypdf-core docs.rs: https://docs.rs/easypdf-core