English

Reliable Digital Signature API to eSign PDF and Office Files

Digitally sign PDF, DOCX, XLSX, PPTX, RTF, TXT, PNG, JPG, GIF, BMP, SVG, PSD, and more files in .NET and Java. eSign files by adding text, image, barcode, and stamp signatures.

View all APIsTry our APIs for Free

Digitally Sign Business Documents in .NET and Java

Digital signatures allow you to sign business documents electronically and remove the hassle of printing, signing, and scanning them. Inserting digital signatures into documents is commonly called electronic signing (or e-signing). eSigns are not only convenient to apply, but they also ensure confidentiality and promote a paperless culture by avoiding printing. Several types of electronic signatures are used for different legal, business, and personal files, as you can incorporate them into documents and images for signing agreements, finalizing contracts, and more.

An electronic signature could also be thought of as a mathematical scheme for demonstrating not only the authenticity but also the integrity of digitally processed files. The native eSign APIs of GroupDocs.Signature for .NET and Java are a must-have for software developers who want to build fully flexible signing apps for popular file formats such as PDF, Microsoft Office, and OpenOffice documents, and images. The secure digital signature APIs for business documents let you add, search, update, or delete multiple types of signatures to your documents and images.

Getting Started

Please review the following information related to API setup before you start signing PDFs and other files with the help of the digital signature APIs for .NET and Java.

GroupDocs.Signature for .NET installation

You can directly download the MSI installer or DLLs from the downloads section to install the best digital signature API for .NET. Alternatively, you can set up the API using the NuGet package. The command for the package manager console is given below.
PM> Install-Package GroupDocs.Signature 

GroupDocs.Signature for Java installation

To install the secure electronic signature API for Java applications, you can visit the downloads section and obtain the JAR files. Or, you can get the latest pom.xml repository and dependency configuration for your Maven-based Java applications.
<repository>
<id>GroupDocsJavaAPI</id>
<name>GroupDocs Java API</name>
<url>http://repository.groupdocs.com/repo/</url>
</repository>
<dependency>
<groupId>com.groupdocs</groupId>
<artifactId>groupdocs-signature</artifactId>
<version>23.6</version>
</dependency>
   

Digital Signature Use Cases

We will now check some of the practical use cases of the cross-platform digital signature APIs for multiple file formats.

Signing PDF and Office Documents with Text, Images, Stamps, and Digital Signatures

Adding an electronic signature, or e-signature to a document is a great way to make sure that the document is valid and can be used for legal, or other specific purposes. e-Signs have mostly replaced the earlier practice of manually signing contracts or legal documents with a pen and paper. An e-signature can be as simple as electronically typing your name into a document or as complex as creating a digital signature and injecting it into the document. GroupDocs.Signature API for digital signing support adding a host of different signature types allowing developers to build apps for signing PDF, MS Office files, and images in .NET and Java. This section will show how to add these signatures to your data files.

Signing PDF and Office Documents with Text, Images, Stamps, and Digital Signatures

Signing PDFs in .NET with text signatures

Using the following C# code, you can insert text-based electronic signatures to PDF documents in your .NET signature solutions:
using (Signature signature = new Signature("sample.pdf"))
{
    TextSignOptions options = new TextSignOptions("John Smith")
    {
        // set signature position
        Left = 100,
        Top = 100,
        // set signature rectangle
        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("sample_signed.pdf", options);
} 

Signing PDF files with text signatures in Java

For adding text signatures to PDF documents using the Java signature libraries, please use the following code snippet:
Signature signature = new Signature("sample.pdf");
TextSignOptions options = new TextSignOptions("John Smith");
// set signature position
options.setLeft(100);
options.setTop(100);

// set signature rectangle
options.setWidth(100);
options.setHeight(30);

// set text color and Font
options.setForeColor(Color.RED);
SignatureFont signatureFont = new SignatureFont();
signatureFont.setSize(12);
signatureFont.setFamilyName("Comic Sans MS");
options.setFont(signatureFont);

// sign document to file
signature.sign("sample_signed.pdf", options); 

Electronically sign your .NET documents using image signatures

You can esign PDFs and other documents by adding image signatures using the following C# coding:
using (Signature signature = new Signature("sample.pdf"))
{
    ImageSignOptions options = new ImageSignOptions("signature.jpg")
    {
        // set signature position
        Left = 100,
        Top = 100,
        AllPages = true
    };
    signature.Sign("SampleSigned.pdf", options);
}  

Effortlessly add image signatures to files in your Java apps

Please use the below-given coding to insert image signatures to your multi-format Java documents:
Signature signature = new Signature("sample.docx");
ImageSignOptions options = new ImageSignOptions("signature.jpg");
// set signature position
options.setLeft(100);
options.setTop(100);
options.setPageNumber(1);
// sign document to file
signature.sign("SampleSigned.docx", options);  

Digitally sign PDF and other files in your C# .NET digital signature apps

Digital signatures could help you with the authenticity of electronically transferred documents. Here’s how to add digital signature to PDF files in C#:
    using (Signature signature = new Signature("sample.pdf"))
{
    // initialize digital option with certificate file path
    DigitalSignOptions options = new DigitalSignOptions("certificate.pfx")
    {
        // optional image setup (file path)
        ImageFilePath = "sample.jpg",
        // set signature position
        Left = 100,
        Top = 100,
        // set
        Password = "1234567890"
    };
    signature.Sign("sampleSigned.pdf", options);
} 

Seamlessly integrate e-signing capabilities into your Java files

Enhance the authenticity of your business files by adding digital signatures to PDF and other documents in Java using the following code snippet:
        Signature signature = new Signature("sample.pdf");
DigitalSignOptions options = new DigitalSignOptions("certificate.pfx");
 // optional image setup (file path)
options.setImageFilePath("sample.jpg");
options.setLeft(100);
options.setTop(100);
options.setPassword("1234567890");
// sign document to file
signature.sign("sampleSigned.pdf", options); 

You can also add stamp, barcode, QR code, and metadata e-signatures to your documents using the digital signature APIs for .NET and Java. If you are a .NET developer, please check out more types of eSignatures and how to add them to your .NET signature solutions. Similarly, if you are a Java developer, you have different virtual signing options for the Java platform too.

Modifying e-Signatures from Within .NET and Java Data Files

While working with PDF, Microsoft Office, OpenOffice, or image files, you may need to update the e-signatures added to these files. It could be challenging if you are up against large volumes of file data but important at the same time to keep document integrity intact. One of the best methods of handling this is automating the modification process by developing a software module that systematically updates the electronic signatures used to sign business documents. This is where GroupDocs.Signature APIs are extremely useful. These high-performance, native digital signature APIs for .NET and Java pack a powerful feature set to update your e-signs easily. In this section, we will deal with updating the text signature and image signatures.

Modifying e-Signatures from Within .NET and Java Data Files

Update text and image signatures in .NET e-signing apps with ease

Manipulate the contents of text signatures by using the below-shared C# code:
// Passing the document to class constructor in which the signature will be updated 
using (Signature signature = new Signature("sampleSigned.pdf"))
{
    TextSearchOptions options = new TextSearchOptions();
    // search for text signatures in document
    List signatures = signature.Search(options);
    if(signatures.Count > 0)
    {
        TextSignature textSignature = signatures[0];
        // change Text property
        textSignature.Text = "John Walkman";
        // change position
        textSignature.Left = textSignature.Left + 10;
        textSignature.Top = textSignature.Top + 10;
        // change size. Please note not all documents support changing signature size
        textSignature.Width = 200;
        textSignature.Height = 100;
        bool result = signature.Update(textSignature);
        if(result)
        {
            Console.WriteLine($"Signature with Text '{textSignature.Text}' was updated in the document ['{fileName}'].");
        }
        else
        {
            Console.WriteLine($"Signature was not updated in the document! Signature with Text '{textSignature.Text}' was not found!");
        }
    }
}    
For changing the image signature contents inside a .NET PDF document, please use this code:
// Pass the document to class constructor in which the signature will be updated
using (Signature signature = new Signature("sampleSigned.pdf"))
{
    ImageSearchOptions options = new ImageSearchOptions();
    // search for image signatures in document
    List signatures = signature.Search(options);
    if(signatures.Count > 0)
    {
        ImageSignature imageSignature = signatures[0];
        // change Image properties
        signatureToUpdate.Top = 200;
        signatureToUpdate.Left = 200;
        signatureToUpdate.Width = 300;
        signatureToUpdate.Height = 150;

        bool result = signature.Update(imageSignature);
        if(result)
        {
            Console.WriteLine($"Signature with Top '{imageSignature.Top}' was updated in the document ['{fileName}'].");
        }
        else
        {
            Console.WriteLine($"Signature was not updated in the document! Signature with Top '{imageSignature.Top}' was not found!");
        }
    }
} 

Modify image and text signatures within your Java apps for customization

Let’s check the code to change or manipulate the contents of the text signature in Java:
Signature signature = new Signature("sampleSigned.pdf");
try {
    TextSearchOptions options = new TextSearchOptions();
    // search for text signatures in document
    List signatures = signature.search(TextSignature.class, options);
    if (signatures.size() > 0) {
        TextSignature textSignature = signatures.get(0);
        // change Text property
        textSignature.setText("John Walkman");
        // change position
        textSignature.setLeft(textSignature.getLeft() + 50);
        textSignature.setTop(textSignature.getTop() + 50);
        // change size. Please note not all documents support changing signature size
        textSignature.setWidth(200);
        textSignature.setHeight(100);
 
        boolean result = signature.update("sampleSigned.pdf",textSignature);
        if (result) {
            System.out.print("Signature with Text '" + textSignature.getText() + "' was updated in the document ['sampleSigned.pdf'].");
        } else {
            System.out.print("Signature was not updated in the document! Signature with Text '" + textSignature.getText() + "' was not found!");
        }
    }
} catch (Exception e) {
    throw new GroupDocsSignatureException(e.getMessage());
}
And here’s the code to programmatically update image signatures in Java documents:
using (Signature signature = new Signature("sampleSigned.pdf"))
{
    ImageSearchOptions options = new ImageSearchOptions();
    // search for image signatures in document
    List signatures = signature.Search(options);
    if(signatures.Count > 0)
    {
        ImageSignature imageSignature = signatures[0];
        // change Image properties
        signatureToUpdate.Top = 200;
        signatureToUpdate.Left = 200;
        signatureToUpdate.Width = 300;
        signatureToUpdate.Height = 150;

        bool result = signature.Update(imageSignature);
        if(result)
        {
            Console.WriteLine($"Signature with Top '{imageSignature.Top}' was updated in the document ['{fileName}'].");
        }
        else
        {
            Console.WriteLine($"Signature was not updated in  the document! Signature with Top '{imageSignature.Top}' was not found!");
        }
    }
} 

Efficiently Search eSigns in PDFs, Microsoft Office Documents, and Images

Searching for the eSigns added to a document lets you verify the authenticity of the document. If you are working in a distributed team, and regularly deal with different kinds of files, the best way would be to use a tool that not only equips you with adding or making signatures but also manipulating and searching them when needed. Based on the search results, any files with the esigns missing could then be re-evaluated and processed accordingly. GroupDocs native .NET and Java digital signature APIs include signature searching features for PDF and other documents, spreadsheets, presentations, and many more data formats. In this section, you will be checking how, in addition to the ability to integrate digital signing in .NET and Java, you can also search for a few different types of e-signatures using the reliable GroupDocs APIs.

Efficiently Search eSigns in PDFs, Microsoft Office Documents, and Images

Locate image signatures in your business documents in .NET

You can build digital signing apps using the .NET e-signature API and search for the image type signatures within your .NET files using the following code:
    using (Signature signature = new Signature("sample.pdf"))
{
    // search document
    List signatures = signature.Search(SignatureType.Image);
    Console.WriteLine($"\nSource document ['{fileName}'] contains following image signature(s).");
    // output signatures
    foreach (ImageSignature imageSignature in signatures)
    {
        Console.WriteLine($"Image signature found at page {imageSignature.PageNumber} with size {imageSignature.Size}. Created {imageSignature.CreatedOn}, modified {imageSignature.ModifiedOn}");
    }
}    
You can also search for many other types of eSigns injected within your files in .NET similarly.

Seamlessly find text e-signatures in your Java documents

Searching for text-based electronic signatures is possible in Java too. Please refer to the following coding example for help with finding the text e-signs in Java documents:
    Signature signature = new Signature(sample.pdf);
 // setup search options
TextSearchOptions options = new TextSearchOptions();
// specify as true to search all pages of a document
options.setAllPages(true);
// search only page with specified number
options.setPageNumber(1);
// specify text math type    
options.setMatchType(TextMatchType.Contains);
// specify text to search
options.setText("John Smith");
 
// search for text signatures in document
List signatures = signature.search(TextSignature.class,options);
// output signatures
for (TextSignature textSignature : signatures)
 {
 
     if (textSignature != null)
     {
         System.out.print("Found Text signature at page "+sign.getPageNumber()+" with type ["+sign.getSignatureImplementation()+"] and text '"+sign.getText()+"'.");
         System.out.print("Location at "+sign.getLeft()+"-"+sign.getTop()+". Size is "+sign.getWidth()+"x"+sign.getHeight()+".");
     }
 } 
Apart from text e-signs, you can also try finding many other types of esigns in Java.

Removing Electronic Signatures from Official and Legal Documents in .NET and Java

When you delete your electronic signature from a document, it's important to understand why you're doing it and the best way to do it. Deleting electronic signatures from documents could be required for a variety of reasons. For instance, the document may no longer be needed or the signer may no longer have a valid reason to keep their signature on the document. Alternatively, the document may have been changed or updated deeming the signature invalid. Regardless of the reasons, GroupDocs.Signature for .NET and Java APIs have the solutions for you. This section will cover how you can remove e-signs from documents using the API for generating and managing digital signatures.

Removing Electronic Signatures from Official and Legal Documents in .NET and Java

Streamline text e-signature removal in .NET digital signature apps

Once you have searched for the text sign in any supported data file, you can delete it as shown in this example with different advanced options:
    // initialize Signature instance
using (Signature signature = new Signature("signed.pdf"))
{
    TextSearchOptions options = new TextSearchOptions();
    List signatures = signature.Search(options);
    List signaturesToDelete = new List();
    // collect signatures to delete
    foreach (TextSignature temp in signatures)
    {
        if (temp.Text.Contains("John"))
        {
            signaturesToDelete.Add(temp);
        }
    }
    // delete signatures
    DeleteResult deleteResult = signature.Delete(signaturesToDelete);
    if (deleteResult.Succeeded.Count == signaturesToDelete.Count)
    {
        Console.WriteLine("All signatures were successfully deleted!");
    }
    else
    {
        Console.WriteLine($"Successfully deleted signatures : {deleteResult.Succeeded.Count}");
        Console.WriteLine($"Not deleted signatures : {deleteResult.Failed.Count}");
    }
    Console.WriteLine("List of deleted signatures:");
    foreach (BaseSignature temp in deleteResult.Succeeded)
    {
        Console.WriteLine($"Signature# Id:{temp.SignatureId}, Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");
    }
}          

Easily remove image e-signatures from documents in Java apps

Here’s how you can search and remove image signatures from your digitally signed files using the Java signature libraries with a few advanced options:
    // initialize Signature instance
Signature signature = new Signature("signed.docx");
ImageSearchOptions options = new ImageSearchOptions();
 
List signatures = signature.search(ImageSignature.class, options);
List signaturesToDelete = new ArrayList();
// collect signatures to delete
for (ImageSignature temp : signatures)
{
    if (temp.getSize() > 10000)
    {
        signaturesToDelete.add(temp);
    }
}
// delete signatures
DeleteResult deleteResult = signature.delete("signed.docx",signaturesToDelete);
if (deleteResult.getSucceeded().size() == signaturesToDelete.size())
{
    System.out.print("All signatures were successfully deleted!");
}
else
{
    System.out.print("Successfully deleted signatures : "+deleteResult.getSucceeded().size());
    System.out.print("Not deleted signatures : "+deleteResult.getFailed().size());
}
System.out.print("List of deleted signatures:");
for(BaseSignature temp : deleteResult.getSucceeded())
{
    System.out.print("Signature# Id:"+temp.getSignatureId()+", Location: "+temp.getLeft()+"x"+temp.getTop()+". Size: "+temp.getWidth()+"x"+temp.getHeight());
} 

GroupDocs.Signature APIs provide many more advanced document e-signature manipulation options for .NET and for Java too. If you are looking for signing PDF, DOCX, PPTX, XLSX, ODS, OTS, or JPEG files on the go, please try the Free Online Digital Signing Apps of GroupDocs.

Independently automate your document and image processing tasks

Why choose GroupDocs?

Unmatched file formats support

  • All popular file formats supported including documents, images, audio, videos, and ebooks.
  • PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX, PUB, PNG, PSD, ODT, MSG, EML, MP3, MP4, and many more.

Extensively programmable libraries

  • Use GroupDocs APIs to build fully customizable .NET and Java apps.
  • Manipulate your business documents, spreadsheets, presentations, and images any way you like.

Hundreds of supported features

  • Convert Word or Excel to PDF, annotate PDFs, edit DOC, DOCX, or watermark files.
  • Work with esignatures, tables, mail-merge, attachments, shapes, and much more.

Tailored to your needs

  • Free trials and different paid licensing options to choose from.
  • Well-suited to individual users, startups, as well as small and large enterprises.

APIs for Developers

  • Programmatically process your digital documents and images in .NET and Java platforms.
  • Document APIs designed specifically for .NET and Java application developers.

Trusted by users globally

  • Preferred by developers and businesses alike, our libraries are used globally.
  • Generate optimised documents easily in standalone and distributed environments.

Do more with your documents and images

  • Create, render, edit, convert, compare, digitally sign, watermark, and export your files.
  • Experience endless possibilities by creating multi-functional, high-performance apps.

Simple integration and convenient application

  • Enjoy greater flexibility by integrating with your existing software applications.
  • Get up and running using a few lines of code with our super-fast and reliable APIs.

Multiple support channels

  • Need help? Look no further than one of our developer-led support options.
  • Explore the APIs structure, and documentation, or dive into the knowledge base.

Ready to get started?

Download Free Trial