From 8901a6743905fe1d5edfeb3b7bd837c8870b28a5 Mon Sep 17 00:00:00 2001 From: Markus Klein Date: Tue, 5 Jun 2018 13:30:11 +0200 Subject: load from arbitrary readers --- src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index e2e5847..b60aeff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -104,10 +104,22 @@ impl PdfObjectDeref for Object { } impl Form { + + /// Takes a reader containing a PDF with a fillable form, analyzes the content, and attempts to + /// identify all of the fields the form has. This is the only way to create a `Form` + pub fn load_from(reader: R) -> Result { + let doc = Document::load_from(reader)?; + Self::load_doc(doc) + } + /// Takes a path to a PDF with a fillable form, analyzes the file, and attempts to identify all /// of the fields the form has. This is the only way to create a `Form` pub fn load>(path: P) -> Result { let doc = Document::load(path)?; + Self::load_doc(doc) + } + + fn load_doc(doc: Document) -> Result{ let mut form_ids = Vec::new(); let mut queue = VecDeque::new(); // Block so borrow of doc ends before doc is moved into the result -- cgit v1.2.3