Browse our Products

Aspose.PDF for .NET 25.7

Improvements and Changes

Plugins

We have added OFD to PDF High Code Plugin product to Aspose.PDF for .NET.


// Specify the input and output paths for the documents.
var inputPath = Path.Combine(@"C:\Samples\", "Sample.ofd");
var outputPath = Path.Combine(@"C:\Samples\", "Ofd2PdfOutput.pdf");

// Create a new instance of the Ofd class.
var plugin = new Pdf.Plugins.Ofd();

// Create a new instance of the OfdToPdfOptions class.
var options = new OfdToPdfOptions();

// Add the input and output paths to the OfdToPdfOptions.
options.AddInput(new FileDataSource(inputPath));
options.AddOutput(new FileDataSource(outputPath));

// Process the OFD to PDF conversion and get the result container.
var resultContainer = plugin.Process(options);

// Get the result from the result container.
var result = resultContainer.ResultCollection[0];

// Print the result to the console.
Console.WriteLine(result);

Features and Enhancements

Starting from version 25.7, you can encrypt a document so that only the owners of the certificates you specify during encryption will be able to open it. The task, ID PDFNET-33384, has been completed at the User’s request. To encrypt the document, you will need the public certificates of all recipients. To open the document, the recipient must have the public certificate and the corresponding private key certificate. The following code snippet shows you how to encrypt PDF document using public certificate.


    // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
    private static void PubSecEncryption(CryptoAlgorithm cryptoAlgorithm)
    {
        // The path to the documents directory
        var dataDir = RunExamples.GetDataDir_AsposePdf_SecuritySignatures();
        // The path to the recipient certificate
        string pubCert = dataDir + "pub_sec.crt";
        string pfx = dataDir + "pub_sec.pfx";
        string pfxPassword = "12345";

        // Create the PDF document
        using (var document = new Aspose.Pdf.Document())
        {
            // Add an info 
            document.Info.Title = "TestTitle";
            document.Info.Author = "TestAuthor";

            // Add a page and add some text
            var page = document.Pages.Add();
            var text = new Aspose.Pdf.Text.TextFragment("Hello World!");
            page.Paragraphs.Add(text);

            // Encrypt the PDF document
            document.Encrypt(Aspose.Pdf.Permissions.PrintDocument, cryptoAlgorithm, new List<System.Security.Cryptography.X509Certificates.X509Certificate2>(){new System.Security.Cryptography.X509Certificates.X509Certificate2(pubCert)});

            // Save the PDF document. A private key certificate must be installed in the storage to open the document by Adobe Acrobat.
            document.Save(dataDir + "pubsec_encrypted_out.pdf");
        }
    }

In some cases, you may need to replace a paragraph of text with a larger amount of content while preserving its original bounding rectangle. An easy way to achieve this is now appearing. You can define a rectangle in which the new text must fit. This enhancement is logged as PDFNET-58922 in our issue tracker.


    // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
    private static void FitTextIntoRectangle()
    {
        // The path to the documents directory
        var dataDir = RunExamples.GetDataDir_AsposePdf_Text();

        // Open PDF document
        using (var document = new Aspose.Pdf.Document(dataDir + "ResizeParagraphSample.pdf"))
        {
            // Extract the paragraph text (or provide the specific text you want to replace)
            var textAbsorber = new Aspose.Pdf.Text.TextAbsorber();
            textAbsorber.Visit(document);
            string paragraphText = textAbsorber.Text;
            paragraphText = paragraphText.Replace(Environment.NewLine, " ");

            // Search for the text fragment
            string searchableContent = Regex.Replace(paragraphText, " ", @"\s+");
            var textFragmentAbsorber = new Aspose.Pdf.Text.TextFragmentAbsorber(
                searchableContent,
                new Aspose.Pdf.Text.TextSearchOptions(true));
            document.Pages.Accept(textFragmentAbsorber);
            Aspose.Pdf.Text.TextFragment textFragment = textFragmentAbsorber.TextFragments[1];

            // Use the text fragment’s rectangle as the target replacement area
            textFragment.ReplaceOptions.Rectangle = textFragment.Rectangle;

            // Enable font size reduction to fit the text within the specified area
            textFragment.ReplaceOptions.FontSizeAdjustmentAction = 
                Aspose.Pdf.Text.TextReplaceOptions.FontSizeAdjustment.ShrinkToFit;

            // Optionally adjust spacing to justify the text width
            textFragment.ReplaceOptions.ReplaceAdjustmentAction = 
                Aspose.Pdf.Text.TextReplaceOptions.ReplaceAdjustment.AdjustSpaceWidth;

            // Duplicate the paragraph content and assign it to the text fragment
            textFragment.Text = paragraphText + " " + paragraphText;

            // Save PDF document
            document.Save(dataDir + "FitTextIntoRectangle_out.pdf");
        }
    }

Starting from version 25.7, we have added the ability to apply a “Cloudy” border effect to the Annotations. This enhancement was made at the User’s request for ID PDFNET-40250 and PDFNET-38862.


    // For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
    private static void AddCloudPolygonAnnotation()
    {
        // The path to the documents directory
        var dataDir = RunExamples.GetDataDir_AsposePdf_Annotations();

        // Create PDF document
        using (var document = new Aspose.Pdf.Document())
        {
            var page = doc.Pages.Add();

            // Add Cloud Polygon (rectangle)
            double left = 100f;
            double top = 270f;
            double right = 420f;
            double bottom = 80f;
            var cloudPolygon = new PolygonAnnotation(
                page,
                new Rectangle(left, top, right, bottom),
                new Point[]
                {
                        new Point(left, top),
                        new Point(right, top),
                        new Point(right, bottom),
                        new Point(left, bottom)
                });

            cloudPolygon.Color = Color.Blue;
            var border = new Border(cloudPolygon);
            border.Width = 3;
            border.Effect = BorderEffect.Cloudy;
            cloudPolygon.Border = border;
            page.Annotations.Add(cloudPolygon);

            // Add another Cloud Polygon
            cloudPolygon = new PolygonAnnotation(
                page,
                new Rectangle(400, 400, 580, 600),
                new Point[]
                {
                        new Point(400, 450),
                        new Point(450, 300),
                        new Point(520, 300),
                        new Point(580, 500),
                        new Point(500, 600)
                });

            cloudPolygon.Color = Color.DarkGreen;
            cloudPolygon.InteriorColor = Color.Aqua;
            border = new Border(cloudPolygon);
            border.Width = 3;
            border.Effect = BorderEffect.Cloudy;
            cloudPolygon.Border = border;
            page.Annotations.Add(cloudPolygon);

            doc.Save(dataDir + "CloudBorder.pdf");
        }
    }

We have updated the version of the dependency System.Net.Http.Json up to 8.0.1. This has been made to avoid a possible transitive dependency vulnerability in earlier versions. This enhancement was made at the User’s request for ID PDFNET-60204.

Other notable enhancements and features

KeySummaryCategory
PDFNET-41681Getting ALT Text Description for the image in PDFFeature
PDFNET-50482XSL-FO to PDF: Reducing conversion timeEnhancement
PDFNET-59892Optimizing the PngDevice rendering logic to improve conversion performanceEnhancement

Bug Fixing and Other Changes

KeySummaryCategory
PDFNET-58942Aspose.Pdf.Comparison.SideBySidePdfComparer.Compare throws System.ArgumentOutOfRangeExceptionBug
PDFNET-58375NullReferenceException : Object reference not set to an instance of an object.Bug
PDFNET-59865Polyline, Polygon, and Cloud Polygon Annotations Not Visible in Chrome and MacOS PreviewBug
PDFNET-43495Annotation is lost with an error dialog after resizing the contentBug
PDFNET-57639Getting a failure when trying to open the attached document with the passwordBug
PDFNET-59085Get Watermark text from PDF is not working - Text is always emptyBug
PDFNET-59106Signatures are added vertically inside PDF pagesBug
PDFNET-59508LineAnnotation Opacity is not setBug
PDFNET-59705Imported polygon annotation is not showingBug
PDFNET-59723pdfEditor.Concatenate Object reference not set to an instance of an objectBug
PDFNET-59769Aspose.Pdf.Document .ctor throws GifImageExceptionBug
PDFNET-59770PDF to PNG - Parameter Not Valid ErrorBug
PDFNET-59854Convert PDF to PDF/A - Font Names transformationBug
PDFNET-59884Converting PS to PDF is taking a long timeBug
PDFNET-59971PDF to DOCX - Space is added in the header, and other issuesBug
PDFNET-59992System.ArgumentOutOfRangeException when using comparisonBug
PDFNET-60028The TextFragment.IsolateTextSegments method implementation is still faultyBug
PDFNET-44095Change default values for Producer and CreatorTool from ‘Aspose.GroupDocs’ to ‘GroupDocs.Metadata’Bug
PDFNET-58455CustomTempFonts folder is constantly growing on .NET Framework 4.6.2 when saving PDF to HTMLBug
PDFNET-45671Problem with digital signature validationBug
PDFNET-57955Error occurs while retrieving the Signature from the PDF DocumentBug
PDFNET-43140StampAnnotation.Opacity property has no effectBug
PDFNET-57722HTML to PDF: Transparent PNG Background Turns WhiteBug
PDFNET-60033PDF to PDF/A: Character missing when using SubsetFonts = trueBug
PDFNET-59849PDF SideBySideComparer errorBug
PDFNET-60093Line dash style ignored when importing XFDFBug
PDFNET-59286Setting the header/footer created a corrupted fileBug
PDFNET-60209PageMarkup regression in macOS environmentBug
PDFNET-57580Table generation with RowSpan generates empty spaceBug
PDFNET-57616NullReferenceException when converting or saving a PDF documentBug
PDFNET-59120A NullReferenceException is thrown during the concatenation of PDF documents.Bug
PDFNET-59341ArgumentOutOfRangeException when comparing PDF document pages with SideBySidePdfComparerBug
PDFNET-59599Exception thrown when updating the text of TextFragmentBug
PDFNET-59852Compressed PDF cannot be opened with Adobe AcrobatBug
PDFNET-59930ArgumentException: “Parameter is not valid.” throws on call RedactionAnnotation.Redact()Bug
PDFNET-59932NullReferenceException thrown when converting a PDF document to markdownBug
PDFNET-56663Error saving to SVGBug
PDFNET-42112When an XFA PDF document is merged with a regular PDF document, the values on the form are lostBug
PDFNET-59886PDF to DOCX - NullReferenceExceptionBug
PDFNET-60070PDF to MD: NullReferenceExceptionBug

Public API and Backward Incompatible Changes

Added APIs

  • Method: Aspose.Pdf.Annotations.Annotation.CreateExtGStateWithOpacity(Aspose.Pdf.XForm) System.Void
  • Field: Aspose.Pdf.Annotations.Annotation.DefaultFontName System.String
  • Field: Aspose.Pdf.Annotations.Annotation.DefaultFontKey System.String
  • Field: Aspose.Pdf.Annotations.Annotation.DefaultFontSize System.Single
  • Method: Aspose.Pdf.Devices.ImageDevice.GetBitmap(Aspose.Pdf.Page) System.Drawing.Bitmap
  • Method: Aspose.Pdf.Document.#ctor(System.IO.Stream,Aspose.Pdf.Security.CertificateEncryptionOptions) System.Void
  • Method: Aspose.Pdf.Document.#ctor(System.IO.Stream,Aspose.Pdf.Security.CertificateEncryptionOptions,System.Boolean) System.Void
  • Method: Aspose.Pdf.Document.#ctor(System.String,Aspose.Pdf.Security.CertificateEncryptionOptions) System.Void
  • Method: Aspose.Pdf.Document.#ctor(System.String,Aspose.Pdf.Security.CertificateEncryptionOptions,System.Boolean) System.Void
  • Method: Aspose.Pdf.Document.Encrypt(Aspose.Pdf.Permissions,Aspose.Pdf.CryptoAlgorithm,System.Collections.Generic.IList{System.Security.Cryptography.X509Certificates.X509Certificate2}) System.Void
  • Type: Aspose.Pdf.Plugins.Ofd
  • Method: Aspose.Pdf.Plugins.Ofd.#ctor System.Void
  • Method: Aspose.Pdf.Plugins.Ofd.Process(Aspose.Pdf.Plugins.IPluginOptions) Aspose.Pdf.Plugins.ResultContainer
  • Method: Aspose.Pdf.Plugins.Ofd.Dispose System.Void
  • Type: Aspose.Pdf.Plugins.OfdToPdfOptions
  • Method: Aspose.Pdf.Plugins.OfdToPdfOptions.#ctor System.Void
  • Property: Aspose.Pdf.Plugins.OfdToPdfOptions.OperationName System.String
  • Property: Aspose.Pdf.Plugins.OfdToPdfOptions.OfdLoadOptions Aspose.Pdf.OfdLoadOptions
  • Type: Aspose.Pdf.Security.CertificateEncryptionOptions
  • Method: Aspose.Pdf.Security.CertificateEncryptionOptions.#ctor(System.String,System.String,System.String) System.Void
  • Method: Aspose.Pdf.Security.CertificateEncryptionOptions.#ctor(System.String,System.Security.Cryptography.X509Certificates.StoreName,System.Security.Cryptography.X509Certificates.StoreLocation) System.Void
  • Method: Aspose.Pdf.Security.CertificateEncryptionOptions.#ctor(System.Security.Cryptography.X509Certificates.X509Certificate2,System.Security.Cryptography.X509Certificates.StoreName,System.Security.Cryptography.X509Certificates.StoreLocation) System.Void
  • Method: Aspose.Pdf.Security.CertificateEncryptionOptions.#ctor(System.Security.Cryptography.X509Certificates.X509Certificate2,System.String,System.String) System.Void
  • Property: Aspose.Pdf.Text.TextReplaceOptions.Rectangle Aspose.Pdf.Rectangle
  • Property: Aspose.Pdf.Text.TextReplaceOptions.FontSizeAdjustmentAction Aspose.Pdf.Text.TextReplaceOptions+FontSizeAdjustment
  • Type: Aspose.Pdf.Text.TextReplaceOptions.FontSizeAdjustment
  • Field: Aspose.Pdf.Text.TextReplaceOptions.FontSizeAdjustment.None
  • Field: Aspose.Pdf.Text.TextReplaceOptions.FontSizeAdjustment.ShrinkToFit
  • Field: Aspose.Pdf.Text.TextReplaceOptions.FontSizeAdjustment.ScaleToFill

Removed APIs

  • Field: Aspose.Pdf.Annotations.Annotation.message1 System.String
  • Method: Aspose.Pdf.Operator.FloatToStr(System.Double) System.String