signpdf | Python script to add signature images to PDFs | Image Editing library
kandi X-RAY | signpdf Summary
kandi X-RAY | signpdf Summary
A quick script to add signature images to PDFs, because I couldn’t find anything that worked well for the purpose under Linux. Pros: should work with most PDFs, and with signatures as PNG’s or JPG’s. It preserves the incoming PDF’s text format (e.g. doesn’t convert every page to images like some alternatives). Cons: no gui yet.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Sign a PDF file
- Get a temporary filename
- Read file contents
signpdf Key Features
signpdf Examples and Code Snippets
Community Discussions
Trending Discussions on signpdf
QUESTION
i was looking for a solution to digitally sign a pdf with a self-signed certificat and came across a video in youtube explaining the process using pdf-lib and node-signpdf libraries. However, after following the instructions it didnt work as intended and encountered a problem:
- i executed the command ( npm i ) and (npm start ) as shown in the github repo of the project.
repo : https://github.com/RichardBray/pdf_sign
Demo ( 8 mins video ) : https://www.youtube.com/watch?v=OFZK5lc70OI&list=PLXUfmx2SIgyICZP-rA84Sle_ghq30W89N&index=4&t=1s
...ANSWER
Answered 2022-Mar-27 at 19:41it appears that the problem is OS related. In fact , the code works fine under linux OS but have some issues with Windows OS related to import command. For windows OS replacing "import" commands with "require" commands solves the problem.
BEFORE:
QUESTION
I have tried to sign pdf using a smart card with Node JS chilkat but it fails. and I found this error when I put the smart card and install here driver on my computer then I execute my code : I cannot find the best solution
...ANSWER
Answered 2022-Feb-16 at 17:27I uploaded a new build here: https://www.npmjs.com/package/@chilkat/ck-node14-win64 It is the version "9.50.89-hotfix1".
Please give it a try. Also, I see you are passing "TnTrust Token" to LoadFromSmartCard. If the problem remains, try passing an empty string. This should cause Chilkat to try using the default Microsoft CNG Storage Provider, which may have better success.
QUESTION
Working with java use Apache PDFBox to sign and certified, invalid certified if signature exist, with JsignPDF was able to certified when approval exist, the process is sign after that do certified (seal) document
Signature with JsignPDF
document after certified with JsignPDF :
the certified invalid with PDFBox
the function from PDFBox with some editing was to try :
...ANSWER
Answered 2022-Jan-25 at 10:00This answer essentially is a more detailed version of the comments, essentially finding that what you want to do is not possible.
You ask for a way to
Certify Document when Approval Signature exist
According to the current PDF specification:
ISO 32000-2:2020 subsection 12.8.1 "General" of 12.8 "Digital signatures" A PDF document may contain the following standard types of signatures: [...] One or more approval signatures (also known as recipient signatures). These shall follow the certification signature if one is present.Thus, you cannot validly add a certification signature to a PDF which already has approval signatures.
(This does not automatically mean that all validators will detect the issue if you add a certification signature after approval signatures, let alone correctly display the cause. Many validators only do a subset of the checks that strictly speaking are necessary...)
More question if the certification signature come first then next is approval like 3 signature approval, can the last the certification setMDPPermission with 1 ? so at the end the document can't add more approval signature
setMDPPermission
adds a DocMDP transform to the signature, and such a transform makes the signature a certification signature. Thus, using this method when signing a document that already has an approval signature, will create an invalid PDF or fail entirely.
You can lock a PDF document with an approval signature, though, if you add a Lock dictionary to the signature field with a P entry of 1. Beware, though, this is a ISO 32000-2 feature originally introduced as a feature of an Adobe Extension to ISO 32000-1. Not all PDF viewers support ISO 32000-2 yet, so some viewers may not respect this entry.
QUESTION
ANSWER
Answered 2021-Sep-13 at 09:12The error message "DocMDP transform method not allowed if an approval signature exists" is correct.
If you want to add a signature to an already signed PDF, simply remove the
QUESTION
I am trying to create a simple app where i can draw a signature over a pdf page that has been turned into a Bitmap. I'm successful on implementing the PDF feature but i'm having trouble implementing the SignaturePad feature in my app.
When i draw on my SignaturePad view, it draws exactly where i dragged on screen. Image: Signature on the drawing pad
However, when i display the resulting bitmap, the signature appears bigger and off-positioned. Image: Signature after displaying the resulting bitmap
I have tried multiple solution offerred to a closely-related problems like:
- https://stackoverflow.com/a/11437439/12209523
- https://stackoverflow.com/a/4013780/12209523
- https://stackoverflow.com/a/5891607/12209523
but none of them worked.
I have 0 (zero) experience of using the android.graphics library so i am clueless about what i'm doing wrong. Any help or suggestions are greatly appreciated!
My SignaturePad Class:
...ANSWER
Answered 2021-Feb-19 at 10:29I figured it out. I logged the width and the height of my custom view on the overridden setImageBitmap
function. Both returns zero. So i logged them again in the onLayout
function, and both of them returns the actual width and height of my custom view.
Finally, i decided to use drawBitmap()
instead of setBitmap()
to resize the bitmap and moved a couple of lines from the setImageBitmap
function to the bottom of onLayout
function.
QUESTION
I do apply a signature to a pdf document via delayed signing(SignDeferred) using IText. The process contains the following steps:
- Prepare the pdf document for siging
- Reserve space for the signature in the pdf document
- Create the hash value of the pdf document
- Create the signature based on the hash value
- Using a self signed certificate
- Apply the signature to the pdf document
The whole process works and i end with a pdf document where the signature is set and is valid.
The original pdf is a PDF-A1a but the resulting pdf is not a valid PDF-A1a anymore. I am aware that there is a documentation about IText PDF-A support (https://kb.itextpdf.com/home/it7kb/ebooks/itext-7-jump-start-tutorial-for-java/chapter-7-creating-pdf-ua-and-pdf-a-documents), but this seems to not apply since i don't change the content of the document.
My question: How can i apply a signature using deferred signing and keep the PDF-A1a in the resulting document?
Note: If i do apply a signature directly (Without SignDeferred), the resulting pdf is still a PDF-A1a, but i do have to use SignDeferred Note: I do use https://www.pdfen.com/pdf-a-validator for checking pdf-A
Code sample- Component used for signing:
- itext.sign 7.1.5.0
- itext.kernel 7.1.5.0
- Component used for creating hash
- BouncyCastle.Crypto 1.8.1.0
The following is a complete code sample sample with everything required in one file. It only requires the references to itext and BouncyCastle and the path to a self signed certificate
...ANSWER
Answered 2020-Nov-27 at 08:00It seems the reason why the signed pdf is no longer a valid PDF-A1a is the estimated size for the signature. I have used a value of about 120kb for the signature.
QUESTION
I m trying to sign PDF on the fly. which i clearly fail to do so. Any help is appreciated.
This is just a test for signing pdf. For the later purpose i'll be saving those private and public key.
The intend is to generate sign PDF on the fly. i followed the code shown in this link
Following are the code snippets.
...ANSWER
Answered 2020-Nov-18 at 17:21QUESTION
I use a modified version of this library: https://github.com/vbuch/node-signpdf#readme in an angular app to sign a pdf with a signature that has been created elsewhere. When I open the signed pdf with foxit reader the signature is invalid with the following message:
Unexpected byte range values defining scope of signed data
Any ideas what the problem could be?
Here is the file: https://drive.google.com/file/d/1eS2waysotpAx6VtHMNvhGvl3wqgiyoT7/view?usp=sharing
...ANSWER
Answered 2020-Nov-16 at 14:56I couldn't reproduce the “Unexpected byte range values defining scope of signed data” error message with the first example document, Foxit "merely" complained that the signature was invalid. Which it indeed is because you forgot to base64-decode the signature string before injecting it into the PDF - PDF requires the embedded signature containers in DER format.
Second Example DocumentThe second example document was shared in a comment:
Now I don't get the error about the byte range anymore but I get new errors: "The document has been altered or corrupted since the Signature was applied." and "The Signer's identity is invalid because it has expired or is not yet valid." and "The signature includes an embedded timestamp but it could not be verified." Not sure if I'm doing it correctly now. This is the new file: https://drive.google.com/file/d/1vsa7thwCsi04r68cdcIsfJG7cT2__-d9/view?usp=sharing
Indeed, the signature container now is injected in DER format, so Foxit Reader can validate it. Concerning the new error messages:
"The document has been altered or corrupted since the Signature was applied." - this indicates here that there is some digest value mismatch.
Calculating and extracting the digest values in question shows that the SHA256 digest value of the signed byte ranges of the document is
QUESTION
I'm using this library https://github.com/vbuch/node-signpdf to sign a pdf document. After I have signed the document I can see the signature when I open the pdf with Foxit reader but not when I open it with Adobe reader DC. I also tried Adobe reader XI but there I can't see it either.
When I open the document in pdf xchange viewer I get this error: non critical errors detected in the xref table.
Any ideas what the problem could be?
That's the file I signed: https://drive.google.com/file/d/1AZvS4sP2Y3FwW4Deod87Dgxc9I0QZkoc/view?usp=sharing
...ANSWER
Answered 2020-Nov-03 at 17:57In your example PDF the name of the signature field consists of 10 bytes, 9 bytes with value 0x00 and one byte with value 0x01. Apparently Adobe Reader does not like that field name.
After some experiments it looks like Adobe Reader does not like a field name starting with a 0x00 byte.
Maybe it contains some code that determines string lengths in a c'ish manner and interprets a 0x00 as end-of-string. A field name with a leading 0x00 byte, therefore, is interpreted as empty string, a field name not accepted by Adobe Reader either.
Thus, please use a signature field name made of (in particular starting with) some meaningful characters. As validators usually display the name of the signature field, this is a good idea anyways.
In terms of lowlevel PDF objects:
The signature field object looks like this:
QUESTION
- Sign a PDF in the browser using cliets certificate store or Smart Card
- For accessing the local cert store I use FortifyApp.
- Pdf is pre-signed on the server using iText(Sharp), then sent to the client via Ajax. Relevant code:
ANSWER
Answered 2020-Jun-29 at 08:51So I figured it out.
Can I achieve my goal without having to manually upload a p12/pfx file, is it even possible?
Yes, it is. (See below on what needs to be changed.)
Is the server-side implementation of the deferred signature correct, do I need something else?
Yes, the code above is fine.
Is the pdf manipulation in javascript correct?
Also fine.
Can I transform the native CrytpoKey to forge or pkijs?
Yes, see below.
What is wrong with the last signature?
@mkl answered it in a comment, thank you.
FortifyApp has a CMS demo now. Although it didn't work with the version I was using, it works with version 1.3.4.
So I went with the pki.js implementation. The code changes need for the signing to be successful are the following:
- Export the certificate:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install signpdf
You can use signpdf like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page