Browse our Products

Aspose.PDF for .NET 25.1

Improvements and Changes

Features and Enhancements

We’ve added an option to save PDF to HTML with skipping all raster images. This feature was made according to the User’s request PDFNET-54697: Auto remove images while converting PDF to HTML.

The following code demonstrates the use of the new option:

private static void SavePdftoHtmlWithoutImages(string inputPdf, string outputHtml)
{
    var htmlSaveOptions = new Aspose.Pdf.HtmlSaveOptions
    {
        FixedLayout = true,
        FontSavingMode = HtmlSaveOptions.FontSavingModes.AlwaysSaveAsWOFF,
        PartsEmbeddingMode = HtmlSaveOptions.PartsEmbeddingModes.EmbedAllIntoHtml,
        RasterImagesSavingMode = HtmlSaveOptions.RasterImagesSavingModes.DontSave,
    };

    using (var document = new Aspose.Pdf.Document(inputPdf))
    {        
        document.Save(outputHtml, htmlOptions);
    }
}

Starting from Aspose.PDF 25.1 it is possible to validate a PDF signature using a Certificate Authority (CA) Server. This was made at the User’s request PDFNET-58842 that was originally reported as a bug.

You can configure certificate validation via OCSP and CRL using the PdfFileSignature.VerifySignature(string signName, ValidationOptions options, out ValidationResult validationResult) method to verify the certificate. You can set the validation options in a ValidationOptions. The ValidationResult contains the certificate verification result. The ValidationOptions contains two settings: ValidationMode and ValidationMethod.

The following code shows the use of the new options:

private static void VerifySignatureWithOptions(string pdfPath)
{
    using (var document = new Aspose.Pdf.Document(pdfPath))
    {
        using (var pdfSign = new Aspose.Pdf.Facades.PdfFileSignature(document))
        {
            foreach (string signName in pdfSign.GetSignNames())
            {
                var options = new Aspose.Pdf.Security.ValidationOptions();
                options.ValidationMode = Aspose.Pdf.Security.ValidationMode.Strict;
                options.ValidationMethod = Aspose.Pdf.Security.ValidationMethod.Auto;
                options.RequestTimeout = 10000;

                Aspose.Pdf.Security.ValidationResult validationResult;
                bool verified = pdfSign.VerifySignature(signName, options, out validationResult);
                Console.WriteLine(validationResult.Status);
                Console.WriteLine(validationResult.Message);
            } 
        }
    }
}

Detailed information on the feature will be added to the documentation soon.

In Aspose.PDF 24.12 we have added cross-platform PDF signature validation using SHA-3 hashing algorithms. This was not announced previously. The necessity of implementation platform-independent validation of SHA-3 came from the fact that the standard .NET library algorithm is limited and is available starting with .NET 8. This task is listed in our issue tracking system with ID PDFNET-58519.

The following code may be used for signing:

private static void SignWithSha3(string inputPdfPath, string cert, string outputPdfPath)
{
    using (var document = new Aspose.Pdf.Document(inputPdfPath))
    {
        using (var pdfSign = new Aspose.Pdf.Facades.PdfFileSignature(document))
        {
            var pkcs = new Aspose.Pdf.Forms.PKCS7Detached(cert, pass, Aspose.Pdf.DigestHashAlgorithm.Sha3_256); // DigestHashAlgorithm.Sha3_384, DigestHashAlgorithm.Sha3_512
            signature.Sign(1, true, new System.Drawing.Rectangle(300, 100, 400, 200), pkcs);
            signature.Save(outputPath);
        }
    }
}

You can use standard code to verify the signature:

private static void VerifySignature(string pdfPath)
{
    using (var document = new Aspose.Pdf.Document(pdfPath))
    {
        using (var pdfSign = new Aspose.Pdf.Facades.PdfFileSignature(document))
        {
            foreach (string signName in pdfSign.GetSignNames())
            {
                bool isValid = pdfSign.VerifySignature(signName);
                Console.WriteLine("Signature '{0}' validation returns {1}", sigName, isValid);
            } 
        }
    }
}

Bug Fixing and Other Changes

KeySummaryCategory
PDFNET-58206PDF File Size Increases After Opening and SavingBug
PDFNET-58859XPS Files Generated by Aspose.PDF Fail to PrintBug
PDFNET-48496PdfPageStamp is causing strange lines around the stamp in output PDFBug
PDFNET-55515Chinese characters are bunched togetherBug
PDFNET-58843System.ArgumentException thrown during verification of valid PDF signaturesBug
PDFNET-58860MemoryFontSource is not working like FileFontSource when specifying SimSun font for OFD on LinuxBug
PDFNET-54956PDF Signature always returning as invalidBug
PDFNET-58432Perfomance regression: Significant slowdown in Annotation.Flatten() execution since version 24.09Bug
PDFNET-57610FloatingBox Position Issue When Added in Different OrdersBug
PDFNET-58639PDF to SVG: Elements are not shown properlyBug
PDFNET-58209Exception thrown when changing FormType to Standard in Evaluation modeBug

Public API and Backward Incompatible Changes

Added APIs

  • Method: Aspose.Pdf.Annotations.RedactionAnnotation.Flatten System.Void
  • Method: Aspose.Pdf.Facades.PdfFileSignature.VerifySignature(System.String,Aspose.Pdf.Security.ValidationOptions,Aspose.Pdf.Security.ValidationResult@) System.Boolean
  • Property: Aspose.Pdf.FloatingBox.PositioningMode Aspose.Pdf.ParagraphPositioningMode
  • Method: Aspose.Pdf.Forms.Field.Flatten System.Void
  • Method: Aspose.Pdf.Forms.Signature.Verify(Aspose.Pdf.Security.ValidationOptions,Aspose.Pdf.Security.ValidationResult@) System.Boolean
  • Field: Aspose.Pdf.HtmlSaveOptions.RasterImagesSavingModes.DontSave
  • Property: Aspose.Pdf.OcspSettings.RequestTimeout System.Int32
  • Type: Aspose.Pdf.ParagraphPositioningMode
  • Field: Aspose.Pdf.ParagraphPositioningMode.Default
  • Field: Aspose.Pdf.ParagraphPositioningMode.Absolute
  • Type: Aspose.Pdf.Security.ValidationMethod
  • Field: Aspose.Pdf.Security.ValidationMethod.Auto
  • Field: Aspose.Pdf.Security.ValidationMethod.Ocsp
  • Field: Aspose.Pdf.Security.ValidationMethod.Crl
  • Field: Aspose.Pdf.Security.ValidationMethod.All
  • Type: Aspose.Pdf.Security.ValidationMode
  • Field: Aspose.Pdf.Security.ValidationMode.None
  • Field: Aspose.Pdf.Security.ValidationMode.OnlyCheck
  • Field: Aspose.Pdf.Security.ValidationMode.Strict
  • Type: Aspose.Pdf.Security.ValidationOptions
  • Method: Aspose.Pdf.Security.ValidationOptions.#ctor System.Void
  • Property: Aspose.Pdf.Security.ValidationOptions.ValidationMode Aspose.Pdf.Security.ValidationMode
  • Property: Aspose.Pdf.Security.ValidationOptions.ValidationMethod Aspose.Pdf.Security.ValidationMethod
  • Property: Aspose.Pdf.Security.ValidationOptions.RequestTimeout System.Int32
  • Type: Aspose.Pdf.Security.ValidationResult
  • Property: Aspose.Pdf.Security.ValidationResult.Status Aspose.Pdf.Security.ValidationStatus
  • Property: Aspose.Pdf.Security.ValidationResult.Message System.String
  • Type: Aspose.Pdf.Security.ValidationStatus
  • Field: Aspose.Pdf.Security.ValidationStatus.Valid
  • Field: Aspose.Pdf.Security.ValidationStatus.Invalid
  • Field: Aspose.Pdf.Security.ValidationStatus.Undefined

Removed APIs

No removings.