Editing a digital signature after a PDF has been signed is a frequent requirement, especially when business rules change or when a signature needs to be repositioned. GroupDocs.Signature Cloud SDK for .NET provides a robust library that lets you programmatically edit Signatures in Signed PDF files without compromising the document’s validity. This guide walks you through a complete, step‑by‑step implementation, covering everything from configuration to downloading the updated file, so you can integrate signature editing into your C# applications with confidence.

Complete Code Example: Edit Signatures in Signed PDF

The following example demonstrates how to edit Signatures in Signed PDF using the GroupDocs.Signature Cloud SDK for .NET.

using System;
using System.Collections.Generic;
using System.IO;
using GroupDocs.Signature.Cloud.Sdk.Api;
using GroupDocs.Signature.Cloud.Sdk.Client;
using GroupDocs.Signature.Cloud.Sdk.Model;
using GroupDocs.Signature.Cloud.Sdk.Model.Requests;

class Program
{
    static void Main()
    {
        // Configuration
        var config = new Configuration
        {
            ClientId = "YOUR_CLIENT_ID",
            ClientSecret = "YOUR_CLIENT_SECRET"
        };

        // API instances
        var signatureApi = new SignatureApi(config);
        var storageApi = new StorageApi(config);

        // File paths
        string inputFilePath = "input.pdf";
        string outputFilePath = "output.pdf";

        // Ensure file exists in storage (upload if needed)
        if (!storageApi.ObjectExists(new ObjectExistsRequest(new StorageExist
        {
            Path = inputFilePath,
            StorageName = null
        })).Exists)
        {
            using (var fileStream = File.OpenRead(inputFilePath))
            {
                storageApi.UploadFile(new UploadFileRequest(new UploadFile
                {
                    Path = inputFilePath,
                    File = fileStream
                }));
            }
        }

        // Get list of signatures in the document
        var fileInfo = new FileInfo
        {
            FilePath = inputFilePath,
            StorageName = null,
            Password = null
        };
        var getSignaturesRequest = new GetSignaturesRequest(new GetSignaturesOptions
        {
            FileInfo = fileInfo
        });
        var signaturesResponse = signatureApi.GetSignatures(getSignaturesRequest);
        if (signaturesResponse.Signatures == null || signaturesResponse.Signatures.Count == 0)
        {
            Console.WriteLine("No signatures found.");
            return;
        }

        // Choose first signature to edit
        var signatureToEdit = signaturesResponse.Signatures[0];
        string signatureId = signatureToEdit.SignatureId;

        // Prepare new options (example: change text signature)
        var textOptions = new SignTextOptions
        {
            // Keep existing properties, modify as needed
            Text = "Edited Signature Text",
            Left = signatureToEdit.Left + 10,
            Top = signatureToEdit.Top + 10,
            Width = signatureToEdit.Width,
            Height = signatureToEdit.Height,
            Font = new SignatureFont
            {
                FontFamily = "Arial",
                FontSize = 12,
                Bold = true,
                Italic = false,
                Underline = false,
                Color = "FF0000"
            },
            // Preserve other required fields
            SignatureId = signatureId,
            PageNumber = signatureToEdit.PageNumber,
            // Set output file path
            OutputFilePath = outputFilePath
        };

        var updateSignatureRequest = new UpdateSignatureRequest(new UpdateSignatureOptions
        {
            FileInfo = fileInfo,
            SignatureId = signatureId,
            Options = textOptions
        });

        var updateResponse = signatureApi.UpdateSignature(updateSignatureRequest);

        // Download updated file
        var downloadRequest = new DownloadFileRequest(new DownloadFile
        {
            Path = outputFilePath,
            StorageName = null
        });
        using (var downloadStream = storageApi.DownloadFile(downloadRequest))
        using (var fileStream = File.Create(outputFilePath))
        {
            downloadStream.CopyTo(fileStream);
        }

        Console.WriteLine("Signature edited and saved to " + outputFilePath);
    }
}

Note: This code example demonstrates the core functionality. Before using it in your project, make sure to update any file paths and configuration values to match your actual environment, verify that all required dependencies are properly installed, and test thoroughly in your development environment. If you encounter any issues, please refer to the official documentation or reach out to the support team for assistance.

cURL Commands for Signature Editing via REST API

Below is a set of cURL commands that perform the same edit Signatures in Signed PDF operation using the REST API.

First, obtain an access token.

curl -X POST "https://api.groupdocs.cloud/v2.0/oauth2/token" \
     -H "Content-Type: application/json" \
     -d '{
           "grant_type":"client_credentials",
           "client_id":"YOUR_CLIENT_ID",
           "client_secret":"YOUR_CLIENT_SECRET"
         }'

Upload the source PDF to cloud storage.

curl -X PUT "https://api.groupdocs.cloud/v2.0/storage/file/input.pdf" \
     -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
     -H "Content-Type: application/octet-stream" \
     --data-binary "@input.pdf"

Update the first signature (example modifies a text signature).

curl -X POST "https://api.groupdocs.cloud/v2.0/signature/update" \
     -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
           "fileInfo": {
               "filePath": "input.pdf"
           },
           "signatureId": "SIGNATURE_ID_FROM_GET",
           "options": {
               "text": "Edited Signature Text",
               "left": 120,
               "top": 150,
               "font": {
                   "fontFamily": "Arial",
                   "fontSize": 12,
                   "bold": true,
                   "color": "FF0000"
               },
               "outputFilePath": "output.pdf"
           }
         }'

Download the updated PDF.

curl -X GET "https://api.groupdocs.cloud/v2.0/storage/file/output.pdf" \
     -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
     -o output.pdf

For more details, see the official API documentation.

Understanding Signature Modification in C#

Below is a concise breakdown of how the provided C# code accomplishes the edit Signatures in Signed PDF workflow.

  1. Configure Authentication - The Configuration object is populated with ClientId and ClientSecret. This establishes a secure session with the cloud service.

    var config = new Configuration { ClientId = "YOUR_CLIENT_ID", ClientSecret = "YOUR_CLIENT_SECRET" };
    
  2. Create API Instances - SignatureApi and StorageApi are instantiated using the configuration, giving access to signature‑related and storage‑related endpoints.

    var signatureApi = new SignatureApi(config);
    var storageApi = new StorageApi(config);
    
  3. Upload If Missing - The code checks whether input.pdf exists in cloud storage; if not, it uploads the file using UploadFile. This ensures the subsequent operations have a source document.

    storageApi.UploadFile(new UploadFileRequest(new UploadFile { Path = inputFilePath, File = fileStream }));
    
  4. Retrieve Existing Signatures - GetSignatures fetches all signatures in the document. The first signature is selected for editing, and its SignatureId is stored.

    var signaturesResponse = signatureApi.GetSignatures(getSignaturesRequest);
    var signatureToEdit = signaturesResponse.Signatures[0];
    
  5. Prepare Updated Options - A new SignTextOptions object copies existing properties and changes the text, position, and font. The SignatureId and PageNumber are preserved to target the correct signature.

    var textOptions = new SignTextOptions { Text = "Edited Signature Text", Left = signatureToEdit.Left + 10, /* ... */ };
    
  6. Execute Update - UpdateSignature sends the modified options to the server, which rewrites the signature while leaving the rest of the PDF untouched.

    var updateResponse = signatureApi.UpdateSignature(updateSignatureRequest);
    
  7. Download Result - Finally, the updated PDF is downloaded from storage to the local file system.

    using (var downloadStream = storageApi.DownloadFile(downloadRequest))
    

For a full list of classes and methods, refer to the API reference.

Getting the Environment Ready

Prepare your development environment before writing any code.

  1. Install the SDK via NuGet

    dotnet add package GroupDocs.signature-Cloud
    

    You can also download the latest package from the release page.

  2. Set Up .NET Runtime - The library requires .NET 6.0 or later. Ensure your project targets a compatible framework.

  3. Create a GroupDocs Cloud Account - Register at the GroupDocs portal and obtain your ClientId and ClientSecret. These credentials are needed for every API call.

  4. Configure Credentials - Store the credentials securely, for example in appsettings.json or environment variables, and reference them when constructing the Configuration object.

  5. Verify Connectivity - Run a simple request (e.g., storageApi.ObjectExists) to confirm that your credentials are valid and the service is reachable.

With these steps completed, you are ready to run the code example and start editing signatures.

Conclusion

Editing Signatures in Signed PDF documents is straightforward with the GroupDocs.Signature Cloud SDK for .NET. By following the steps above, you can locate an existing signature, modify its visual properties, and preserve the document’s integrity all from a C# application. Remember to secure a proper license for production use; you can purchase a full license or obtain a temporary license from the temporary license page. Start integrating signature editing today and streamline your document workflows.

FAQs

  • Can I edit Signatures in Signed PDF without breaking the signature’s validity?
    Yes. The SDK updates only the visual representation while keeping the cryptographic hash intact, so the document remains valid.

  • What is the difference between edit Signatures in Signed PDF and edit Signatures in Signed PDF in .NET?
    The former describes the generic operation, while the latter emphasizes that the implementation uses the .NET version of the GroupDocs.Signature Cloud SDK.

  • Do I need to re‑sign the PDF after editing a signature?
    No. The SDK modifies the appearance of the existing signature object; the original digital signature remains unchanged.

  • Is there a sample project I can download?
    Yes, a complete sample is available in the GitHub repository: https://github.com/groupdocs-signature-cloud/groupdocs-signature-cloud-dotnet.

Read More