Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Created August 29, 2019 11:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/4a7557ad2b26d344f2fd97f3f0bd55d8 to your computer and use it in GitHub Desktop.
Save GroupDocsGists/4a7557ad2b26d344f2fd97f3f0bd55d8 to your computer and use it in GitHub Desktop.
using (Signature signature = new Signature("sample.pdf"))
{
    TextSignOptions options = new TextSignOptions("John Smith")
    {
        // locate signature
        Left = 100, Top = 100, Width = 100, Height = 30,
        // set text color and font
        ForeColor = Color.Red,
        Font = new SignatureFont { Size = 12, FamilyName = "Comic Sans MS" }
    };
    // sign document to file
    signature.Sign("signed.pdf", options);
}
// setup configuration
SignatureConfig signConfig = new SignatureConfig
{
    StoragePath = @"c:\Storage",
    OutputPath = @"c:\Output"
};
// instantiate the signature handler
SignatureHandler handler = new SignatureHandler(signConfig);
// setup text signature options
PdfSignTextOptions signOptions = new PdfSignTextOptions("John Smith")
{
    // locate signature
    Left = 100, Top = 100, Width = 100, Height = 30,
    // set text color and Ffont
    ForeColor = Color.Red,
    Font = new SignatureFont { FontSize = 12, FontFamily = "Comic Sans MS" }
};
SaveOptions saveOptions = new SaveOptions { OutputType = OutputType.String, OutputFileName = "signed.pdf" };
// sign document
string signedPath = handler.Sign<string>("test.pdf", signOptions,saveOptions);
Console.WriteLine("Signed file path is: " + signedPath);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment