Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on filling in pdf form #205

Open
buhaytza2005 opened this issue Dec 14, 2023 · 4 comments
Open

Error on filling in pdf form #205

buhaytza2005 opened this issue Dec 14, 2023 · 4 comments

Comments

@buhaytza2005
Copy link

I was very happy to read that the functionality to fill in dynamic pdfs is coming to this library.

Unfortunately, there seems to be an error, at least for the pdf I am trying to work with. This may be something very minor but I am the beginning of my journey with Rust and it could be that I am just understanding how to use the example.

I cloned the repo and added my file to the files folder then I have executed the following:

cargo build
./target/debug/form files/template_form.pdf

The output of this was:

read: files/template_form.pdf
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Try { file: "pdf/src/file.rs", line: 609, column: 23, context: Context([]), source: FromPrimitive { typ: "RcRef < Catalog >", field: "root", source: Shared { source: FromPrimitive { typ: "Option < InteractiveFormDictionary >", field: "forms", source: FromPrimitive { typ: "Vec < RcRef < FieldDictionary > >", field: "fields", source: Shared { source: MissingEntry { typ: "Rect", field: "rect" } } } } } } }', examples/src/bin/form.rs:17:54
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I am attaching the pdf I am trying to work with in the hope that someone can point me in the right direction.

Thanks!
template_form.pdf

@s3bk
Copy link
Contributor

s3bk commented Dec 14, 2023

If you want, modify the FieldDictionary struct and wrap the rect field in an Option. (And make a PR with it if it solves the problem.)

It is very much work in progress so there are definitely more bugs to be found.

@buhaytza2005
Copy link
Author

Tried the suggested fix and it appears at least part of it was taken care of.

However, now I am encountering the below:

read: files/template_form.pdf
thread 'main' panicked at examples/src/bin/form.rs:17:54:
called `Result::unwrap()` on an `Err` value: Try { file: "pdf/src/file.rs", line: 609, column: 23, context: Context([]), source: FromPrimitive { typ: "RcRef < Catalog >", field: "root", source: Shared { source: FromPrimitive { typ: "Option < InteractiveFormDictionary >", field: "forms", source: FromPrimitive { typ: "Vec < RcRef < FieldDictionary > >", field: "fields", source: Shared { source: MissingEntry { typ: "Name", field: "subtype" } } } } } } }

I can see that the InteractiveFormDictionary does not have a subtype field, tried adding it - copied one from Annotation struct and I seemed to have gotten another error now

read: files/template_form.pdf
thread 'main' panicked at examples/src/bin/form.rs:17:54:
called `Result::unwrap()` on an `Err` value: Try { file: "pdf/src/file.rs", line: 609, column: 23, context: Context([]), source: FromPrimitive { typ: "RcRef < Catalog >", field: "root", source: Shared { source: FromPrimitive { typ: "Option < InteractiveFormDictionary >", field: "forms", source: MissingEntry { typ: "Name", field: "subtype" } } } } }

Tried to poke around at what that could mean but not really got anywhere so if there are any suggestions or pointers I am more than happy to keep poking but I went down the path of macros and that is waaay over my head.

@s3bk
Copy link
Contributor

s3bk commented Dec 14, 2023

I fixed the bugs and improved the Error display so you should be able to figure out where it needs fixing next time.

@vaijira
Copy link

vaijira commented Mar 17, 2024

This is another pdf that is having problems parsing the annotations:

thread 'main' panicked at examples/src/bin/form.rs:46:59:
can't load annotations: FromPrimitive { typ: "Option < MaybeRef < AppearanceStreams > >", field: "appearance_streams", source: FromPrimitive { typ: "Ref < AppearanceStreamEntry >", field: "normal", source: UnexpectedPrimitive { expected: "Reference", found: "Dictionary" } } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants