Skip to content

Commit

Permalink
fix form example
Browse files Browse the repository at this point in the history
  • Loading branch information
s3bk committed Jan 21, 2024
1 parent ea591ba commit 18d9427
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions examples/src/bin/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use pdf::font::{Font, FontData, TFont};
use pdf::object::*;
use pdf::primitive::{PdfString, Primitive, Name};

fn main() -> Result<(), PdfError> {
fn run() -> Result<(), PdfError> {
let path = args().nth(1).expect("no file given");
println!("read: {}", path);

let mut file = FileOptions::cached().open(&path).unwrap();
let mut file = FileOptions::cached().open(&path)?;
let mut to_update_field: Option<_> = None;


Expand Down Expand Up @@ -43,8 +43,7 @@ fn main() -> Result<(), PdfError> {
let resources = file.create(resources)?;

let page0 = file.get_page(0).unwrap();
for &annot in &page0.annotations {
let annot = file.resolver().get(annot)?;
for annot in &page0.annotations {
if let Some(ref a) = annot.appearance_streams {
let normal = file.resolver().get(a.normal);
if let Ok(normal) = normal {
Expand Down Expand Up @@ -117,3 +116,9 @@ fn main() -> Result<(), PdfError> {

Ok(())
}

fn main() {
if let Err(e) = run() {
println!("{e}");
}
}

0 comments on commit 18d9427

Please sign in to comment.