Print Page | Close Window

Signing a password protected document

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: Sample Code
Forum Description: Share Debenu Quick PDF Library sample code with other forum members
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3728
Printed Date: 22 Nov 24 at 1:16PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Signing a password protected document
Posted By: Bigun
Subject: Signing a password protected document
Date Posted: 24 Jul 19 at 12:25PM
Hi all,
I've been required to digitally sign an already password protected document with no success.
I'm using QuickPdf v11.13. So far I can digitally sign unprotected PDFs, with or without images, with no problem. Basically:
- NewSignProcessFromFile(...)
- SetSignProcessPFXFromFile(...)
- SetSignProcessFieldBounds(...)
- SetSignProcessFieldImageFromFile(...)
- EndSignProcessToFile(SignedPdf)  // SignedPdf= new signed PDF
res= GetSignProcessResult(...).  // OK

But the same process with a password protected PDF does not sign the resulting PDF. This protected PDF already has an empty signature field and has no constraints filling fields, signing...

The original protected PDF (password; owner) is
https://we.tl/t-x0JuwBxfqQ
The resulting not signed PDF is:
https://we.tl/t-uh06rFQf1r

Can anyone guide me or give me any hint?
Thank you very much




Replies:
Posted By: Ingo
Date Posted: 24 Jul 19 at 8:33PM
Hi Bigun,

did you read the description regarding NewSignProcessFromFile?
https://www.debenu.com/docs/pdf_library_reference/NewSignProcessFromFile.php
There you can read:
"...Creates a new digital signature process using a file as the source document...".
There is a password as parameter ;-)
If the password is protected the original owner wanted to protect it ;-)
If it's only the main password you can do it this way:
// ...
      QP.LoadFromFile(FileName, '');
      If QP.EncryptionStatus > 0 Then
        QP.Decrypt;
// ...
then you can begin with your signing process.

Cheers and welcome here,
Ingo




-------------
Cheers,
Ingo



Posted By: Bigun
Date Posted: 26 Jul 19 at 8:49AM
Thank you for your answer Ingo, but I'm afraid I'm already starting the signing process using it:

int SignProcessID= QP->NewSignProcessFromFile(sSourcePdf, sOwnerPassword);
...

If I decrypt SourcePdf as you suggest, the signature process goes well but I'm not able to Encrypt the resulting signed PDF, so I get a signed unprotected PDF:

int Permisos= QP->EncodePermissions(1, 0, 0, 0, 1, 1, 0, 1);
int iRes= QP->Encrypt(sPassOwner, "", Strength, Permisos);
QP->SetSignProcessPFXFromFile(SignProcessID, PFXFileName, PFXPassword);
...
QP->EndSignProcessToFile(SignProcessID, sOutput);  // <== should be signed and password protected
 
On the other hand, if I don't decrypt it, the resulting file, though protected, does not get signed.

I'll keep trying. Thanks for your help!!


Posted By: Ingo
Date Posted: 26 Jul 19 at 8:52PM
Hi Bigun,

here's a kb-document from Debenu:
https://www.debenu.com/kb/add-visual-digital-signature-to-a-pdf-programmatically/

With this link you'll find interesting hints from Rowan:
http://www.quickpdf.org/forum/visible-digital-signature_topic2563.html

A quick read through the content lt me think that signing doesn't need a password?
If you simply rewrite the pdf the signature is broken and all readers are telling that the signature in the loaded pdf was broken...



-------------
Cheers,
Ingo




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk