ralpha / pdf_signing Goto Github PK
View Code? Open in Web Editor NEWRust library for adding signatures and digitally sign PDF documents.
License: Apache License 2.0
Rust library for adding signatures and digitally sign PDF documents.
License: Apache License 2.0
When a document is signed by running the sign_doc.rs the information defined in the UserSignatureInfo struct is ignored by acrobat. Instead it takes user information from the certificate instead.
UserSignatureInfo {
user_id: "272".to_owned(),
user_name: "Charlie".to_owned(),
user_email: "[email protected]".to_owned(),
user_signature: std::fs::read("./examples/assets/sig1.png").unwrap(),
user_signing_keys: signer.clone(),
}
Currently there is an issue with this package that does not allow the signatures to be verified in Adobe after the image objects have been inserted into the document.
In the code after the graphics are inserted into the document the graphics state is restored:
content.operations.push(Operation::new("Q", vec![]));
Commenting out this line will result in a valid signed document with signature images embedded in the document. What is the purpose of this line and is it fine if we remove this?
Hi @ralpha
Thanks for this project its great. I am just trying it out now but not sure what data I am meant to be referencing with the form_id
field.
doc_new
.add_signature_to_form(img.as_bytes(), "image", page_id, form_id)
.unwrap();
I assume its a reference to a dictionary with the width, height etc values but not too sure.
Cheers,
Josh
Hi @ralpha ,
I have been trying to run your example after creating all required certs, unfortunately I'm getting this error.
error: failed to select a version for the requirement `lopdf = "^0.27.0"`
candidate versions found which didn't match: 0.29.0
location searched: Git repository https://github.com/J-F-Liu/lopdf?branch=master
required by package `pdf_signing v0.1.0 (/path/to/project/folder)`
I have tried to change lopdf version to 0.29.0, I'm getting the following errors.
error[E0631]: type mismatch in function arguments
--> src/image_xobject.rs:172:73
|
172 | let bbox: lopdf::Object = Array(identity_matrix.into_iter().map(Real).collect());
| --- ^^^^
| | |
| | expected due to this
| | found signature defined here
| required by a bound introduced by this call
|
= note: expected function signature `fn(f64) -> _`
found function signature `fn(f32) -> _`
note: required by a bound in `map`
--> /home/egovridc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/traits/iterator.rs:779:12
|
779 | F: FnMut(Self::Item) -> B,
| ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `map`
error[E0599]: the method `collect` exists for struct `std::iter::Map<std::vec::IntoIter<f64>, fn(f32) -> lopdf::Object {lopdf::Object::Real}>`, but its trait bounds were not satisfied
--> src/image_xobject.rs:172:79
|
172 | let bbox: lopdf::Object = Array(identity_matrix.into_iter().map(Real).collect());
| ^^^^^^^ method cannot be called on `std::iter::Map<std::vec::IntoIter<f64>, fn(f32) -> lopdf::Object {lopdf::Object::Real}>` due to unsatisfied trait bounds
|
::: /home/egovridc/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/iter/adapters/map.rs:61:1
|
61 | pub struct Map<I, F> {
| -------------------- doesn't satisfy `_: Iterator`
|
= note: the following trait bounds were not satisfied:
`<fn(f32) -> lopdf::Object {lopdf::Object::Real} as FnOnce<(f64,)>>::Output = _`
which is required by `std::iter::Map<std::vec::IntoIter<f64>, fn(f32) -> lopdf::Object {lopdf::Object::Real}>: Iterator`
`fn(f32) -> lopdf::Object {lopdf::Object::Real}: FnMut<(f64,)>`
which is required by `std::iter::Map<std::vec::IntoIter<f64>, fn(f32) -> lopdf::Object {lopdf::Object::Real}>: Iterator`
`std::iter::Map<std::vec::IntoIter<f64>, fn(f32) -> lopdf::Object {lopdf::Object::Real}>: Iterator`
which is required by `&mut std::iter::Map<std::vec::IntoIter<f64>, fn(f32) -> lopdf::Object {lopdf::Object::Real}>: Iterator`
error[E0599]: no method named `as_f64` found for enum `lopdf::Object` in the current scope
--> src/signature_image.rs:134:47
|
134 | ... x1: child_rect[0].as_f64()?,
| ^^^^^^ help: there is an associated function with a similar name: `as_i64`
error[E0599]: no method named `as_f64` found for enum `lopdf::Object` in the current scope
--> src/signature_image.rs:135:47
|
135 | ... y1: child_rect[1].as_f64()?,
| ^^^^^^ help: there is an associated function with a similar name: `as_i64`
error[E0599]: no method named `as_f64` found for enum `lopdf::Object` in the current scope
--> src/signature_image.rs:136:47
|
136 | ... x2: child_rect[2].as_f64()?,
| ^^^^^^ help: there is an associated function with a similar name: `as_i64`
error[E0599]: no method named `as_f64` found for enum `lopdf::Object` in the current scope
--> src/signature_image.rs:137:47
|
137 | ... y2: child_rect[3].as_f64()?,
| ^^^^^^ help: there is an associated function with a similar name: `as_i64`
Some errors have detailed explanations: E0599, E0631.
For more information about an error, try `rustc --explain E0599`.
error: could not compile `pdf_signing` due to 6 previous errors
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.