Print Page | Close Window

Visible digital signature

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2563
Printed Date: 26 Apr 24 at 1:38AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Visible digital signature
Posted By: struhadlo
Subject: Visible digital signature
Date Posted: 12 Mar 13 at 11:53AM
Hi,

I downloaded trial version and want to make visible digital signature. Can somebody please help me how can i make visible signature? Is it possible to make visible digital signature with Debenu Quick PDF Library?

I use Delphi 7 with DebenuQuickPDFLibrary0913 on WindowsXP.

The code, which i tried, open input pdf file, then create FormField with SetSignProcessField command (from manual: The created field will be invisible (zero width and height) and will be attached to the first page in the document.), but don't return its ID. When i want to find it by its name, function FindFormFieldByTitle returns 0 (The form field could not be found.)
How can i use function SetFormFieldSignatureImage, when i need to pass it signature form field? I tried make newFormField, but it didn't reach the desired result (maybe i did some mistake).

Thanks for any advice
Petr Gabriel

const
FORMFIELD_NAME = 'DIGITAL_SIGNATURE';
var
PDFLibrary: TDebenuPDFLibrary0913;
UnlockResult: Integer;
SignProcessID: Integer;
ImageID: Integer;
FormFieldIndex: Integer;
begin
PDFLibrary:= TDebenuPDFLibrary0913.Create();
try
    UnlockResult:= PDFLibrary.UnlockKey(MY_UNLOCK_KEY);
    if UnlockResult = 1 then begin
      SignProcessID:= PDFLibrary.NewSignProcessFromFile('c:\home\input.pdf', '');
      if SignProcessID = 0 then begin
        MessageDlg('Error: NewSignProcessFromFile', Dialogs.mtError, [Dialogs.mbOK], 0);
        Exit;
      end;
      if PDFLibrary.SetSignProcessField(SignProcessID, FORMFIELD_NAME) = 0 then begin
        MessageDlg('Error: SetSignProcessField', Dialogs.mtError, [Dialogs.mbOK], 0);
        Exit;
      end;
      MessageDlg('FormFieldCount: ' + IntToStr(PDFLibrary.FormFieldCount()),
                  Dialogs.mtInformation, [Dialogs.mbOK], 0);
      FormFieldIndex:= PDFLibrary.FindFormFieldByTitle(FORMFIELD_NAME);
      if FormFieldIndex = 0 then begin
        MessageDlg('Error: FindFormFieldByTitle', Dialogs.mtError, [Dialogs.mbOK], 0);
        Exit;
      end;
      if PDFLibrary.SetFormFieldVisible(FormFieldIndex, 1) = 0 then begin
        MessageDlg('Error: SetFormFieldVisible', Dialogs.mtError, [Dialogs.mbOK], 0);
        Exit;
      end;
      if PDFLibrary.SetFormFieldBounds(FormFieldIndex, 25, 500, 100, 100) = 0 then begin
        MessageDlg('Error: SetFormFieldBounds', Dialogs.mtError, [Dialogs.mbOK], 0);
        Exit;
      end;
      ImageID:= PDFLibrary.AddImageFromFile('C:\home\logo.gif', 0);
      if ImageID = 0 then begin
        MessageDlg('Error: AddImageFromFile', Dialogs.mtError, [Dialogs.mbOK], 0);
        Exit;
      end;
      if PDFLibrary.SelectImage(ImageID) = 0 then begin
        MessageDlg('Error: SelectImage', Dialogs.mtError, [Dialogs.mbOK], 0);
        Exit;
      end;
      if PDFLibrary.SetFormFieldSignatureImage(FormFieldIndex, PDFLibrary.SelectedImage(), 0) = 0 then begin
        MessageDlg('Error: SetFormFieldSignatureImage', Dialogs.mtError, [Dialogs.mbOK], 0);
        Exit;
      end;
      if PDFLibrary.SetSignProcessInfo(SignProcessID, 'Reason: Test', 'Location: CZ', 'Contact: PhoneNumber') = 0 then begin
        MessageDlg(Error: SetSignProcessInfo, Dialogs.mtError, [Dialogs.mbOk], 0);
        Exit;
      end;
      if PDFLibrary.SetSignProcessPFXFromFile(SignProcessID, 'c:\home\cacert\cacert.p12', MY_CERT_PASSWORD) = 0 then begin
        MessageDlg(Error: SetSignProcessPFXFromFile, Dialogs.mtError, [Dialogs.mbOK], 0);
        Exit;
      end;
      PDFLibrary.EndSignProcessToFile(SignProcessID, 'c:\home\output.pdf');
    end
    else
      MessageDlg('Invalid lincese key', Dialogs.mtError, [Dialogs.mbOK], 0);
finally
    PDFLibrary.Free();
end;
end;



Replies:
Posted By: Ingo
Date Posted: 12 Mar 13 at 10:18PM
Hi!

Andrew hat shown in an earlier post how to "see" a digital signature:
http://www.quickpdf.org/forum/how-do-i-detect-that-a-pdf-has-a-digital-signature_topic2529_post10489.html?KW=FormFieldType#10489

Cheers and welcome here,
Ingo



Posted By: tfrost
Date Posted: 13 Mar 13 at 12:10AM
The simple answer is that you can not do this today.  Ingo has kindly provided a solution for a question you did not ask, about detecting whether a PDF is signed.

Nothing I have tried has enabled me to create a standard, functioning, visible signature field with Debenu, which looks like those you can make with Acrobat or Nitro Pro.  I have used both 9.12 and 9.13 and I have two outstanding support cases on this issue, but no solution.  I urge you to open a fresh support issue in the hope that you may have better luck.

Back in December (18/12/2012) I had a response from Andrew saying "We are currently working on the beefing up the SignFile functionality with new functions and features.  When this is finished we will be documenting all the new features and will have sample code showing how to use the new functions".  This would be great if if had happened, but no sign of it after nearly three months.  If functions were available and working to do what both you and I need, I cannot see how it could possibly take so long to produce a simple example of how to do it, which is what I requested.  Hence the conclusion in my first sentence.


Posted By: struhadlo
Date Posted: 14 Mar 13 at 1:57PM
Thanks you for reply. So I can only wait for new information/version.


Posted By: kevindebenu
Date Posted: 17 Mar 13 at 2:09PM
struhadlo and tfrost,

Debenu Quick PDF Library 9.14 will include two new functions:
SetSignProcessFieldImageFromFile
SetSignProcessFieldBounds

These will allow the creation of a digital signature with an appearance stream containing the specified image.

Look out for the first beta of 9.14 due out soon.

-Kevin


Posted By: Rowan
Date Posted: 19 Mar 13 at 8:11AM
Hi Guys,

Debenu Quick PDF Library 9.14 Beta 1 has been released and can be downloaded from the http://www.debenu.com/blog/debenu-quick-pdf-library-9-14-beta-1-released.html - Debenu Blog .

Here is some Delphi sample code that demonstrates how to use the new visual digital signature feature:

------------------------------------------------
procedure TForm7.btnNewSignProcessFromFileClick(Sender: TObject);
var
SignProcessID: Integer;
begin
    DPL := TDebenuPDFLibrary0914.Create;
    if DPL.UnlockKey('..license_key_goes_here') = 1 then
    begin
      DPL.DrawText(100, 700, 'This is the file to be signed');
      DPL.SaveToFile('TheUnsignedFile.pdf');

      SignProcessID := DPL.NewSignProcessFromFile('TheUnsignedFile.pdf', '');
      if (SignProcessID > 0) then
      begin
        DPL.SetSignProcessPFXFromFile(SignProcessID, 'qpl_test.pfx', 'testing');
        DPL.SetSignProcessInfo(SignProcessID, 'To test digital signatures', 'The World', 'Contact me');
        DPL.SetSignProcessField(SignProcessID, 'Contract Signature');
        DPL.SetSignProcessFieldBounds(SignProcessID, 100, 600, 200, 100);
        DPL.SetSignProcessFieldImageFromFile(SignProcessID, 'visualsignature.jpg', 0);
        DPL.EndSignProcessToFile(SignProcessID, 'TheSignedFile.pdf');
      end;
    end;
end;
------------------------------------------------

If you experience any issues with this please let us know.

Cheers,
- Rowan.


Posted By: Chumly
Date Posted: 28 Apr 13 at 6:04AM
Hi,
I'm having troubles getting this to work in asp using the ActiveX module...
Result all come back as '1' until the EndSignProcessToFile which returns '0'. But that does not tell me why.

Using the second method, (SignFile) it returns '7' which says it has the wrong password.
However, the same data works fine using jSignPDF.
Can you help me understand what the requirements of the pfx file is that will allow me to get rid of jsignpdf?
Code in use:
     SigProcID = QP.NewSignProcessFromFile(FilePath,OpenPassword)
     result = QP.SetSignProcessInfo(SigProcID,Reason,Location,ContactInfo)
     response.write "Result: "& result & "<br>" & vbCrLf
     result = QP.SetSignProcessField(SigProcID,"DigitalSignature")
     response.write "Result: "& result & "<br>" & vbCrLf
     result = QP.SetSignProcessFieldBounds(SigProcID, 100, 600, 200, 100)
     response.write "Result: "& result & "<br>" & vbCrLf
    result = QP.SetSignProcessFieldImageFromFile(SigProcID, SigImageFile, 0)
     response.write "Result: "& result & "<br>" & vbCrLf
     result = QP.SetSignProcessPFXFromFile(SigProcID,PFXFileName,PFXPassword)
     response.write "Result: "& result & "<br>" & vbCrLf
     result = QP.EndSignProcessToFile(SigProcID, OutputFileName)
     response.write "Result: "& result & ", Path: " & OutputFileName & "<br>" & vbCrLf

     result = QP.SignFile(FilePath, "", SignaturesFieldName, OutputFileName, PFXFileName, PFXPassword, Reason, Location, ContactInfo)
     response.write "Result: "& result & ", Path: " & OutPutFileName & "<br>" & vbCrLf


Output:
Saved: c:\inetpub\wwwroot\test\1367103662.pdf
Result: 1
Result: 1
Result: 1
Result: 1
Result: 1
Result: 0, Path: c:\inetpub\wwwroot\test\1367103662-signed.pdf
Result: 7, Path: c:\inetpub\wwwroot\test\1367103662-signed.pdf



Posted By: tfrost
Date Posted: 28 Apr 13 at 11:15AM
In my testing (of 9.14b4), the (undocumented) return code from the EndSignProcessToFile function is always zero whether or not the signature is valid, though no file is written if not.  I have a support ticket open and I know Debenu are working on the signatures for 9.14.  You do not need the SignFile as well as the EndSignProcessToFile.


Posted By: Rowan
Date Posted: 18 Nov 13 at 12:46AM
Hi Guys,

The result returned by EndSignProcessToFile will always be zero. To check the result of the digital signature signing process call the GetSignProcessResult function.

The documentation has been updated to reflect this and the change will be in Debenu Quick PDF Library 10.12 Beta 2.

Cheers,
- Rowan.


Posted By: tfrancois
Date Posted: 14 Jul 15 at 6:18PM
Hello,

I am having the same issue with the incorrect password with a valid PFX and password.  What did you do to solve this issue?   I am at a complete loss.   I am considering purchasing the product, but with no indication that its working it may not make sense to make the investment.

Thanks,

Teddy.


Posted By: tfrost
Date Posted: 17 Jul 15 at 3:13PM
This thread was about showing a visible signature block when a PDF is digitally signed.  If you are getting an error indicating an invalid password, that is something different: if the signature cannot be loaded, it clearly cannot be applied, with or without a visible presence.  Please show your actual code and the exact error return that you get, and someone may be able to help.


Posted By: tfrancois
Date Posted: 17 Jul 15 at 4:41PM
Thank you for your reply.

I was able to solve the issue.  The PFX file was saved in the Computer's Personal certificate store so I had to use the SetSignProcessKeyset to 2 - Crypt Machine Keyset instead of leaving the default 1 - Crypt User Keyset set.

Once I made that change, it worked perfectly.  Hope this helps someone else.


Posted By: ixm7
Date Posted: 03 Oct 18 at 9:30PM
Instead of specifying a custom image file to fit into the digital signature form field, is there a way to generate the type of default Acrobat Digital Signature image generated by Acrobat digital signature?



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