Digitally Sign PDF and Create PDF/A-3B Compliant PDF in C#

Aspose.Pdf for .NET logo

Like in the last few releases, the specific focus of Aspose.Pdf development has been towards the PDF to HTML conversion feature. In adding more value to this functionality we have added a new feature: creating subsequent files with body contents only when converting multi-page PDF to HTML format. In order to accomplish this requirement, a new property, HtmlSaveOptions.HtmlMarkupGenerationMode has been introduced. With the following simple code snippet, you can split an output HTML to pages and force the HTML objects on the output pages to go exactly where they are now (fonts processing and output, CSS creation and output, images creation and output), except that resultant HTML will contain contents currently placed inside tags (now “body” tags will be omitted). However when using this approach, linking to CSS will be the responsibility of your code, because things like ” will be stripped out. For this purpose, you may read the CSS via File.ReadAllText() and send it via AJAX to a web page where it will be applied by jQuery. Further details, can be found in the article on the basics of PDF to HTML conversion.

Digitally Signing PDF with Timestamp Server

We have introduced a feature that lets you digitally sign PDF documents using time-stamp servers. A new class named TimestampSettings has been added. For further details, please visit the Digitally Signing PDF with Timestamp Server article.

Convert PDF to PDF/A_3b

Over the years, Aspose.Pdf for .NET has proved to be a great API for converting PDF files to PDF/A format. In this latest release, we have introduced the support for converting PDF files to PDF/A_3b compliant format. In order to support this feature, the value PDF_A_3B has been added to the PdfFormat enumeration. Please take a look at the following code snippet for further details. Convert PDF File to PDF-A.

Printing PDFs with Windows Service

We received a request regarding the printing of PDFs via a Windows Service because of System.Drawing.Printing is not supported by Microsoft in a Service. In order to resolve this problem, you need to first convert the PDF file to XPS format using Aspose.Pdf for .NET while using the following code snippet.

// Load source PDF file
Aspose.Pdf.Document doc = new Aspose.Pdf.Document("1.pdf");
// Save output in XPS format
doc.Save("1.xps", new Aspose.Pdf.XpsSaveOptions());

Once the PDF file is converted to XPS format, you can use Aspose.Words for .NET to print a document on a server via XPSPrint. In this approach, the System.Drawing.Printing namespace is not used (XpsConverter uses the System.Drawing namespace as it’s not as bad as using System.Drawing.Printing in web-services).

HTML to PDF – Support Resource Loading Callback

HTML to PDF is an important Aspose.Pdf for .NET feature. In this release, we have introduced a new feature regarding resource loading callback when converting HTML files to PDF format. In order to accomplish this requirement, a new property – HtmlSaveOptions.CustomLoaderOfExternalResources – has been introduced. Please note that this feature works when options.UseNewConversionEngine has the value of true. This custom strategy replaces pictures that are referenced in HTML with one predefined picture Custom_picture.PNG. Therefore in order to ensure this feature works :

  1. Please put all supplied files in the test folder, open HTML in the browser, and see the original page where DrWeb’s logo referenced in HTML.
  2. Execute the code and take a look into the result. The DrWeb logo will be replaced with Custom_picture.PNG because CustomLoaderOfExternalResources refers to custom code that substitutes pictures.

For further details, please take a look at the article HTML to PDF – Resource Loading Callback.

XML to FDF conversion

FDF stands for Forms Data Format, and an FDF file contains form values in a key/value pair. We also know that an XML file contains the values as tags, where, mostly the key is represented as the tag name, and value is represented as the value within that tag. Now, Aspose.Pdf.Facades provides the flexibility to convert any FDF file into XML. So with this release, you get the option to either

XSL-FO to PDF with New DOM

Conversion of XSL-FO files to PDF format using legacy Aspose.Pdf for .NET (the current Aspose.Pdf.Generator namespace) is one of the salient features of our API and many customers are already using this feature. Now we have also introduced this feature to the Aspose.Pdf namespace and, as shown in the following code snippet, the XslFoLoadOptions class can be used to accomplish this feature.

string inFo = @"F:\ExternalTestsData\33897.fo";
string outPdf = @"F:\ExternalTestsData\33897.pdf";

XslFoLoadOptions options = new XslFoLoadOptions();
// Indicate to use the new conversion engine
options.UseOldXslFoEngine = false;

Document pdfDocument = new Document(inFo, options);
pdfDocument.Save(outPdf);

Also please note that the current implementations of encryption/decryption and hashing functions are FIPS compliant. Along with the above-listed features, we have made numerous enhancements to PDF to TIFF conversion, working with annotations, bookmark manipulation, filling forms, PDF to HTML conversion, HTML to PDF conversion, PDF to Microsoft Excel worksheet conversion, adding an image to PDF file and much more.

Please download and start exploring the new features in Aspose.Pdf for .NET 9.2.0.