Latest release (September 2024)
This page contains release notes for GroupDocs.Signature for .NET 24.9
The release of GroupDocs.Signature version 24.9 includes bug fixes and new features.
Full list of changes in this release
Key | Category | Summary |
---|---|---|
SIGNATURENET-5077 | ★ Feature | Implement Document Preview options PreviewOptions.Resolution property |
SIGNATURENET-5242 | 🔧 Fix | Image is invisible in digital signature on PDF files |
Major features
Including the ability to preview documents with customizable resolution using the PreviewOptions.Resolution property
public static void GetPreview()
{
// The path to the documents directory.
string filePath = "sample.pdf";
using (Signature signature = new Signature(filePath))
{
int resolution = 96;
// create preview options object
PreviewOptions previewOption = new PreviewOptions(CreatePageStream, ReleasePageStream, resolution)
{
PreviewFormat = PreviewOptions.PreviewFormats.JPEG,
// set property to hide all known signatures
HideSignatures = true
};
// generate preview
signature.GeneratePreview(previewOption);
}
}
private static Stream CreatePageStream(PreviewPageData pageData)
{
string imageFilePath = Path.Combine("PreviewFolderPath", "image-0" + pageData.PageNumber.ToString() + ".jpg");
var folder = Path.GetDirectoryName(imageFilePath);
if(!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
return new System.IO.FileStream(imageFilePath, FileMode.Create);
}
private static void ReleasePageStream(PreviewPageData pageData, Stream pageStream)
{
pageStream.Dispose();
string imageFilePath = Path.Combine("PreviewFolderPath", "image-0" + pageData.PageNumber.ToString() + ".jpg");
Console.WriteLine("Image file {0} is ready for preview", imageFilePath);
}
The following image shows the preview of sample.pdf with different Resolution
value:
Fix image visibility issue in digital signatures on PDF files
This fix allows users to properly display images within their digital signatures
string sourceFile = "sample.pdf";
string outputFile = "result.pdf";
string password = "1234567890";
string imageFilePath = "signature-01.jpg";
string certFile = "test-cert.pfx";
using (Signature signature = new Signature(sourceFile))
{
// initialize digital option with certificate file path
DigitalSignOptions options = new DigitalSignOptions(certFile)
{
// certifiate password
Password = "1234567890",
// digital certificate details
Reason = "Sign",
Contact = "JohnSmith",
Location = "Office1",
// image as digital certificate appearance on document pages
ImageFilePath = imageFilePath,
// set signature location
Width = 200,
Height = 100,
Margin = new Padding() {Bottom = 100, Right = 100},
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = HorizontalAlignment.Right,
};
signature.Sign(outputFile, options);
}