Foxit Quick PDF Library

Add visual digital signature to a PDF programmatically

Foxit Quick PDF Library lets you add visual digital signatures to PDF files programmatically with a few simple lines of code. It lets you sign existing signature form fields or will automatically create a signature form field with the name that you specify as part of the signing process.

Here is some C# and Delphi sample code which demonstrates how to sign a PDF file with a visual signature.

Contents

Delphi

DPL.DrawText(100, 700, 'This is the file to be signed');
DPL.SaveToFile('TheUnsignedFile.pdf');

SignProcessID := DPL.NewSignProcessFromFile('TheUnsignedFile.pdf', ''); // Add an Integer var for SignProcessID
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');
  DPL.ReleaseSignProcess(SignProcessID); // Releases a signature process from memory
end;

C#

DPL.DrawText(100, 700, "This is the file to be signed");
DPL.SaveToFile("TheUnsignedFile.pdf");

int SignProcessID = DPL.NewSignProcessFromFile("TheUnsignedFile.pdf", ""); // Add an Integer var for SignProcessID
if (SignProcessID > 0)
{
  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");
  DPL.ReleaseSignProcess(SignProcessID); // Releases a signature process from memory
}

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

Foxit Quick PDF Library also lets you add document level digital signatures, signatures that are not visible on the page, to PDF files using the SignFile function.

This article refers to a deprecated product. If you are looking for support for Foxit PDF SDK, please click here.

Updated on May 16, 2022

Was this article helpful?
Thanks for your feedback. If you have a comment on how to improve the article, you can write it here: