diff options
| author | jsandler18 | 2018-06-09 08:50:50 -0400 |
|---|---|---|
| committer | GitHub | 2018-06-09 08:50:50 -0400 |
| commit | 5b593bd686e91a2e15640a6f77aedd5d1a893e50 (patch) | |
| tree | 9fe8a404b34eb21cb83e867096878b12956372f8 | |
| parent | 103cbbc604da6fc22681b29b0fea2658b86539dd (diff) | |
| parent | e55ee0393cde9cd49cd41c3872d658de89408440 (diff) | |
| download | pdf_form-5b593bd686e91a2e15640a6f77aedd5d1a893e50.tar.bz2 | |
Merge pull request #1 from pacman82/master
load from arbitrary readers
| -rw-r--r-- | src/lib.rs | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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. + pub fn load_from<R: io::Read>(reader: R) -> Result<Self, LoadError> { + 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` + /// of the fields the form has. pub fn load<P: AsRef<Path>>(path: P) -> Result<Self, LoadError> { let doc = Document::load(path)?; + Self::load_doc(doc) + } + + fn load_doc(doc: Document) -> Result<Self, LoadError>{ let mut form_ids = Vec::new(); let mut queue = VecDeque::new(); // Block so borrow of doc ends before doc is moved into the result |
