aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index e2e5847..b3d925a 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.
+ 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