Skip to content

Commit d24f48f

Browse files
authored
Merge pull request #287 from aspose-pdf/WhatsNew_24_10_PDFNET_58239
Add "What’s new in Aspose.PDF" for v.24.10
2 parents 5625dbb + bd0cae1 commit d24f48f

File tree

1 file changed

+80
-1
lines changed

1 file changed

+80
-1
lines changed

net/whatsnew/_index.md

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,88 @@ description: In this page introduces the most popular new features in Aspose.PDF
88
sitemap:
99
changefreq: "monthly"
1010
priority: 0.8
11-
lastmod: "2024-09-06"
11+
lastmod: "2024-10-18"
1212
---
1313

14+
## What's new in Aspose.PDF 24.10
15+
16+
The Elliptic Curve Digital Signature Algorithm (ECDSA) is a modern cryptographic algorithm known for providing strong security with smaller key sizes compared to traditional algorithms. Since version 24.10, it has been possible to sign PDF documents using ECDSA, as well as verify ECDSA signatures. The following elliptic curves are supported for creating and verifying digital signatures:
17+
* P-256 (secp256r1).
18+
* P-384 (secp384r1).
19+
* P-521 (secp521r1).
20+
* brainpoolP256r1.
21+
* brainpoolP384r1.
22+
* brainpoolP512r1.
23+
24+
The SHA-256 hash algorithm is used for generating the signature. ECDSA signatures can be verified using the following hash algorithms: SHA-256, SHA-384, SHA-512, SHA3-256, SHA3-384, and SHA3-512.
25+
26+
You can use your usual code to sign documents with ECDSA and to verify signatures:
27+
28+
```cs
29+
public void Sign(string cert, string inputPdfFile, string outFile)
30+
{
31+
32+
using (Document document = new Document(inputPdfFile))
33+
{
34+
using (PdfFileSignature signature = new PdfFileSignature(document))
35+
{
36+
PKCS7Detached pkcs = new PKCS7Detached(cert, "12345");
37+
signature.Sign(1, true, new System.Drawing.Rectangle(300, 100, 400, 200), pkcs);
38+
signature.Save(outFile);
39+
}
40+
}
41+
}
42+
43+
public static void Verify(string fileName)
44+
{
45+
46+
using (Document document = new Document(fileName))
47+
{
48+
using (PdfFileSignature signature = new PdfFileSignature(document))
49+
{
50+
var sigNames = signature.GetSignNames();
51+
foreach (var sigName in sigNames)
52+
{
53+
bool isValid = signature.VerifySignature(sigName);
54+
Console.WriteLine("Signature '{0}' validation returns {1}", sigName, isValid);
55+
}
56+
}
57+
}
58+
}
59+
```
60+
61+
Sometimes, it is necessary to crop an image before inserting it into a PDF. We have added an overloaded version of the `AddImage()` method to support adding cropped images:
62+
63+
```cs
64+
65+
var imagePath = "";
66+
var resultPdfPath = "";
67+
68+
using (Document document = new Document())
69+
{
70+
using (Stream imgStream = File.OpenRead(imagePath))
71+
{
72+
// Define the rectangle where the image will be placed on the PDF page
73+
Rectangle imageRect = new Rectangle(17.62, 65.25, 602.62, 767.25);
74+
75+
// Crop the image to half its original width and height
76+
var w = imageRect.Width / 2;
77+
var h = imageRect.Height / 2;
78+
Rectangle bbox = new Rectangle(imageRect.LLX, imageRect.LLY, imageRect.LLX + w, imageRect.LLY + h);
79+
80+
// Add a new page to the document
81+
Page page = document.Pages.Add();
82+
83+
// Insert the cropped image onto the page, specifying the original position (imageRect)
84+
// and the cropping area (bbox)
85+
page.AddImage(imgStream, imageRect, bbox);
86+
}
87+
88+
// Save the document to the specified file path
89+
document.Save(resultPdfPath);
90+
}
91+
```
92+
1493
## What's new in Aspose.PDF 24.9
1594

1695
Since version 24.9, it has been possible to generate a crash report when the library throws an exception. A crash report includes information about the type of exception, application title, Aspose.Pdf version, OS version, error message, and stack trace.

0 commit comments

Comments
 (0)