Spire.PDF 12.5.1 现已正式发布。该版本在数字签名中新增支持 SHA-2 和 SHA-256 算法,同时修复了一些问题,例如打印 PDF 时内容丢失的问题。更多详情如下。
新功能:
- 数字签名新增支持 SHA-2 和 SHA-256 算法。
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(inputFile);
X509Certificate2 cert = new X509Certificate2(inputFile_pfx, "e-iceblue");
IPdfSignatureFormatter formatter = new PdfPKCS7Formatter(cert, false);
PdfMDPSignatureMaker pdfMDPSignatureMaker = new PdfMDPSignatureMaker(pdf, formatter);
PdfSignature signature = pdfMDPSignatureMaker.Signature;
signature.Name = "e-iceblue";
signature.ContactInfo = "028-81705109";
signature.Location = "chengdu";
signature.Reason = " this document";
PdfSignatureAppearance appearance = new PdfSignatureAppearance(signature);
appearance.NameLabel = "Signer: ";
appearance.ContactInfoLabel = "ContactInfo: ";
appearance.LocationLabel = "Loaction: ";
appearance.ReasonLabel = "Reason: ";
pdfMDPSignatureMaker.MakeSignature("signName", pdf.Pages[0], 100, 100, 250, 200, appearance);
foreach (HashAlgorithmType hashAlgorithmType in Enum.GetValues(typeof(HashAlgorithmType)))
{
if (string.Equals(hashAlgorithmType.ToString(), "SM3", StringComparison.OrdinalIgnoreCase))
{
continue;
}
//default value of HashAlgorithm is SHA256
formatter.Properties.HashAlgorithm = hashAlgorithmType;
try
{
pdf.SaveToFile( "out.pdf", FileFormat.PDF);
}
catch (Exception ex)
{
Console.WriteLine($"error:{ex.Message}");
}
}
pdf.Dispose();
问题修复:
- 修复了打印 PDF 时内容丢失的问题。
- 修复了 PDF 转图片时程序抛出 “ArgumentException” 异常的问题。
- 修复了合并 PDF 文档时程序抛出 “Object reference not set to an instance of an object” 异常的问题。
- 修复了使用指定字体填充 PdfTextBoxField 内容后,再获取字体不正确的问题。
- 修复了结果文档保存时覆盖源文件,程序抛出 “IndexOutOfRangeException” 异常的问题。
获取 Spire.PDF 12.5.1 请点击:







