EldoS | Feel safer!

Software components for data protection, secure storage and transfer

PDFBlackbox---Adding several signatures at once

Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.
#23865
Posted: 03/01/2013 03:54:53
by Peter Lidbaum (Basic support level)
Joined: 02/22/2013
Posts: 4

Hi EldoS!

Just a short "basic" question---I'm trying to add several signatures to the same PDF document. I had lots of issues with this until I started *saving* the document between each signature, then everything works.

So do I really have to save the document for each signature, is there no way to load the PDF document, add three signatures and then save it just once?

Thanks / All the best,

/Peter
#23866
Posted: 03/01/2013 03:57:45
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

Quote
I had lots of issues with this until I started *saving* the document between each signature, then everything works.

Could you clarify what exact issues did you get.
#23868
Posted: 03/01/2013 04:27:12
by Dmytro Bogatskyy (EldoS Corp.)

Quote
So do I really have to save the document for each signature, is there no way to load the PDF document, add three signatures and then save it just once?

In fact, a component saves and reload a document if you add more then one signature at a time.
Please ensure that you are not reusing objects (like TElPDFSignature and TElPDFPublicKeySecurityHandler) for different signatures.
#23890
Posted: 03/01/2013 08:51:41
by Peter Lidbaum (Basic support level)
Joined: 02/22/2013
Posts: 4

Quote
Could you clarify what exact issues did you get.

I had problems with an exception in TElPDFDocument::Close(), but after reexamining the code I found the problem. I had just rearranged the sample code you sent me without much thought/analysis, so I had at the "main" level;

Code
  TElPDFDocument oDoc(NULL);

  oDoc.Open(fs);

  FAddSignatureToDoc(oDoc, <more params>);
  FAddSignatureToDoc(oDoc, <more params>);

  oDoc.Close(true);

and then the FAddSignatureToDoc() function contained direct objects such as

Code
  TElPDFPublicKeySecurityHandler oPublicKeyHandler(NULL);

and:

Code
  TElX509Certificate oCert(NULL);

that are used in TElPDFDocument::Close().

Since they are deleted when they go out of scope when the FAddSignatureToDoc() function returns, I get an exception when Close() tries to use them later on. Allocating these dynamically:

Code
  TElX509Certificate* pCert = new TElX509Certificate(NULL);

solves the problem, but then I'll somehow have to keep track of them to make sure I delete them at the end---after the Close() call---in order to avoid any memory leaks...and then maybe it is easier to just save/load the document several times, especially if that is what happens anyway, "behind the scenes"...


Quote
In fact, a component saves and reload a document if you add more then one signature at a time.

Yes, after managing to add several signatures at once I compared the output PDFs in a text editor, and the results are more or less identical when adding several signatures at once and when adding them one-by-one...

Thanks / All the best,

/Peter
#23896
Posted: 03/01/2013 12:11:56
by Dmytro Bogatskyy (EldoS Corp.)

Quote
I had problems with an exception in TElPDFDocument::Close(), but after reexamining the code I found the problem. I had just rearranged the sample code you sent me without much thought/analysis, so I had at the "main" level;
...

Yes, signing performed in Document.Close method, so you should free TElPDFPublicKeySecurityHandler and TElMemoryCertStorage objects after calling a Close method.
As for TElX509Certificate object, you can free it after you have added into CertStorage object (Add method copies a certificate into certificate storage).
Also by EldoS: CallbackFilter
A component to monitor and control disk activity, track file and directory operations (create, read, write, rename etc.), alter file data, encrypt files, create virtual files.

Reply

Statistics

Topic viewed 1110 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!