GroupDocs.Signature for .NET 24.10 Release Notes

The release of GroupDocs.Signature version 24.10 includes bug fixes and enhancement.

Full list of changes in this release

KeyCategorySummary
SIGNATURENET-5253🔧 FixIterative signing of digital signatures doesn’t work when an image or appearance is set
SIGNATURENET-5242🔧 FixThe signing process does not maintain the original PDF document permissions
SIGNATURENET-5270EnhancementAdjust the signing process to preserve existing digital signatures in the PDF document

Major fixes

The signing process does not maintain the original PDF document permissions

The signing process previously did not maintain the original PDF document permissions, which impacted users’ ability to control access and modifications after signing. To address this issue, we have introduced two new properties in PdfSaveOptions: Permissions and PermissionsPassword. The Permissions property allows users to define specific permissions such as print, copy, or edit restrictions that can be applied to the PDF document during the signing process. The PermissionPassword property enables users to set a password for modifying permissions, ensuring that security settings are enforced consistently across the document. These enhancements empower users to either retain existing permissions or define new ones, providing greater control over PDF document security after signing.

        // Using the Signature class to create a signature for the specified PDF document
        using (Signature signature = new Signature("sample.pdf"))
        {
            TextSignOptions textSignOptions = new TextSignOptions("JohnSmith")
            {
                Left = 0,
                Top = 100,
                Width = 100,
                Height = 100,
                AllPages = true,
                ForeColor = Color.Black,
            };

            // Create a new PdfSaveOptions object to configure the PDF save settings
            PdfSaveOptions saveOptions = new PdfSaveOptions();
            saveOptions.Password = "1234567890";
            saveOptions.OverwriteExistingFiles = false;
            // Set permissions to deny printing and modification
            saveOptions.Permissions = Permissions.DenyPrinting | Permissions.DenyModification;
            // Set a password for modifying permissions(optional)
            saveOptions.PermissionsPassword = "0987654321";

            // Sign the document and save the result to a new file
            signature.Sign("result.pdf", textSignOptions, saveOptions);
        }

Iterative signing of digital signatures doesn’t work when an image or appearance is set

We have resolved this issue, allowing users to now set an image or appearance during the iterative signing process while still maintaining valid certificates. This enhancement ensures that users can personalize their signatures without compromising the integrity of their digital signatures.

        string sourceFile = "sample.pdf";
        string imageFilePath = "image.jpg";

        string signedFile = "signed.pdf";
        string resultOutputFile = "result.pdf";

        string[] certificatePaths = new string[] { certificateFilePath1, certificateFilePath2 };
        int iteration = 0;
        foreach (var certificatePath in certificatePaths)
        {
            using (Signature signature = new Signature("sample.pdf"))
            {
                DigitalSignOptions options = new DigitalSignOptions(certificatePath)
                {
                    // certifiate password
                    Password = "1234567890",
                    // digital certificate details
                    Reason = "Sign",
                    Contact = "JohnSmith" + iteration,
                    Location = "Office1" + iteration,
                    Visible = true,
                    Left = 80 + iteration * 5,
                    Top = 600 + iteration * 5,
                    Height = 50 + iteration * 5,
                    Width = 200 + iteration * 5,
                    // image as digital certificate appearance on document pages
                    ImageFilePath = imageFilePath
                };

                options.Appearance = new PdfDigitalSignatureAppearance
                {
                    ReasonLabel = "Reason Label",
                    DigitalSignedLabel = "Digital Signed Label",
                };

                if (iteration == 1)
                {
                    signedFile = resultOutputFile;
                }

                SignResult signResult = signature.Sign(signedFile, options);
                Console.WriteLine(
                    $"\nSource document signed successfully {iteration++}-time with " +
                    $"{signResult.Succeeded.Count} signature(s).\nFile saved at {signedFile}.");
            }

            sourceFile = signedFile;
        }