GroupDocs.Signature for .NET 23.7 Release Notes

There are several features, enhancements, and bug fixes in this release.

Full list of changes in this release

KeyCategorySummary
SIGNATURENET-4605★ FeatureImplement verification DICOM image documents for signatures
SIGNATURENET-4574★ FeatureImplement preview for DICOM image documents
SIGNATURENET-4595★ FeatureRespect saving XmpData package for DICOM
SIGNATURENET-4598★ FeatureImplement gathering extended DICOM XmpData into the DocumentInfo
SIGNATURENET-4602EnhancementProvide size and position for image search result Barcode and QrCode signatures
SIGNATURENET-4599🔧 FixSearch processing does not give expected results due to evaluation message in internal output images
SIGNATURENET-4504🔧 FixWrong signature position for documents signed in archives

Major Features

This release includes four new DICOM image format features:

Implement verification DICOM image documents for signatures

🌐 The verification process within the DICOM documents does not look different than verification for single-page raster image, except for the fact that all result images will contain the page number of the layer where the signature was verified.

/// <summary>
/// Verify multi-layer image document for signatures.
/// This example provided for formats like DICOM
/// </summary>
using (Signature signature = new Signature("signed.dcm"))
{
   QrCodeVerifyOptions options = new QrCodeVerifyOptions()
    {
        AllPages = true,
        Text = "Patient #36363393",
        MatchType = TextMatchType.Contains
    };

    VerificationResult result = signature.Verify(options);
    if (result.IsValid)
    {
        Console.WriteLine($"\nDICOM {filePath} has {result.Succeeded.Count} successfully verified signatures!");
    }
    else
    {
        Helper.WriteError($"\nDocument {filePath} failed verification process.");
    }
}

Implement preview for DICOM image documents

🌐 How to preview the DICOM image information

/// <summary>
/// Generate preview for DICOM document 
/// </summary>
using (Signature signature = new Signature("signed.dcm"))
{
    PreviewOptions previewOption = new PreviewOptions(CreatePageStream, ReleasePageStream)
    {
        PreviewFormat = PreviewOptions.PreviewFormats.PNG,
    };

    signature.GeneratePreview(previewOption);
    Console.WriteLine($"\nDICOM ['{filePath}'] pages previews were successfully generated!");
}

 private static Stream CreatePageStream(int pageNumber)
{
    string imageFilePath = Path.Combine(Constants.OutputPath, "SignDicomImage", "preview-" + pageNumber.ToString() + ".jpg");
    var folder = Path.GetDirectoryName(imageFilePath);
    if (!Directory.Exists(folder))
    {
        Directory.CreateDirectory(folder);
    }
    return new FileStream(imageFilePath, FileMode.Create);
}

private static void ReleasePageStream(int pageNumber, Stream pageStream)
{
    pageStream.Dispose();
}

Respect saving XmpData package for DICOM

🌐 In this release, we’ve introduced extended DICOM XmpData DicomXmpType to provide ability to get and update DICOM metadata. It may be done using [DicomSaveOptions] (https://reference.groupdocs.com/signature/net/groupdocs.signature.options/dicomsaveoptions/)

/// <summary>
/// Sign multi-layer image document and add xmp metadata
/// </summary>
using (var signature = new Signature("sample.dcm"))
{
    QrCodeSignOptions options = new QrCodeSignOptions("Patient #36363393. R: No-Issues")
    {
        // set QR area
        Width = 100,
        Height = 100,
        // put right bottom corner
        VerticalAlignment = VerticalAlignment.Bottom,
        HorizontalAlignment = HorizontalAlignment.Right,
        Margin = new Padding() { Right = 5, Left = 5 }
    };

    DicomSaveOptions dicomSaveOptions = new DicomSaveOptions()
    {
        XmpEntries = new List<DicomXmpEntry>() { new DicomXmpEntry(DicomXmpType.PatientName, "Patient #4") }        
    };

    SignResult signResult = signature.Sign(outputFilePath, options, dicomSaveOptions);
}

Implement gathering extended DICOM XmpData into the DocumentInfo

/// <summary>
/// Gathering extended DICOM XmpData into the DocumentInfo
/// </summary>
using (var signature = new Signature("sample.dcm"))
{
    Console.WriteLine($"\nList of DICOM xmp metadata:");
    IDocumentInfo signedDocumentInfo = signature.GetDocumentInfo();
    foreach (var item in signedDocumentInfo.MetadataSignatures)
    {
        Console.WriteLine(item.ToString());
    }
}