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
Printed Date: 03 Jun 20 at 12:01AM
Software Version: Web Wiz Forums 11.01 -

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
The resulting not signed PDF is:

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

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

did you read the description regarding NewSignProcessFromFile?
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
// ...
then you can begin with your signing process.

Cheers and welcome here,


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:

With this link you'll find interesting hints from Rowan:

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...


Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 -
Copyright ©2001-2014 Web Wiz Ltd. -