Digitally Sign PDF Documents and Verify Digital Signatures using C#

Digital Signatures are used to secure PDF documents before they are shared with third parties. Digitally signing a PDF document makes it possible to detect the tampering by verifying the document using the digital signature. In order to secure the PDF documents programmatically using digital signatures, this article will show you how to digitally sign and verify a PDF document in C#. Ultimately, you will learn how to:

  • Digitally sign PDF documents using C#.
  • Digitally sign PDF documents with a Timestamp server in C#.
  • Verify digital signature in PDF using C#.

C# API for Digitally Signing PDF Documents

In order to add and verify digital signatures in PDF documents, we’ll use Aspose.PDF for .NET API which is a powerful PDF manipulation API for creating, editing, converting and digitally signing PDF documents. You can download Aspose.PDF for .NET or install it using one of the following ways in Visual Studio:

NuGet Package Manager

Digitally Sign PDF in C#

Package Manager Console

PM> Install-Package Aspose.PDF

Digitally Sign PDF Documents in C#

The following are the steps to sign a PDF document using Aspose.PDF for .NET.

  • Create an object of the Document class and initialize it with the PDF document’s path.
  • Create an object of PdfFileSignature class and initialize it with the Document class’s object.
  • Create an object of PKCS7 class and initialize it with a certificate path and password.
  • Create and initialize the object of DocMDPSignature class for the MDP signature type.
  • Create a Rectangle for signature placement.
  • Digitally sign PDF document using PdfFileSignature.Certify() method.
  • Save the document using PdfFileSignature.Save() method.

The following code sample shows how to add a digital signature to a PDF document in C#.

Digitally Sign PDF Documents with Timestamp Server in C#

You can also sign a PDF document with the TimeStamp server by providing its details using the TimestampSettings class. The following code sample shows how to digitally sign a PDF document with a TimeStamp server in C#.

Verify Digital Signatures in PDF using C#

You can verify the digitally signed PDF document using the following steps:

  • Create an object of the Document class and initialize it with the PDF document’s path.
  • Create an object of PdfFileSignature class and initialize it with the Document class’s object.
  • Access all the signatures of the PDF document.
  • Verify the validity of the signature using PdfFileSignature.VerifySigned() method.

The following code sample shows how to verify the digital signature in PDF using C#.

Try Aspose.PDF for .NET for Free

You can get a free temporary license to try and use Aspose.PDF for .NET.

Posted in Aspose.PDF Product Family | Tagged , , | Leave a comment

ASP.NET PowerPoint Viewer – Display PowerPoint Presentations in ASP.NET

Display PPT PPTX in ASP.NET Core

Are you looking for a PowerPoint Viewer to view or embed presentations in your ASP.NET Core web application? If yes, continue to read this article and learn how to create a simple ASP.NET Core PowerPoint Viewer and display PPT/PPTX presentations using C#. So let’s begin.

Features of ASP.NET PowerPoint Viewer

Our ASP.NET PowerPoint Viewer will use Aspose.Slides for .NET API to render the presentation slides as PNG images. Once the slides are rendered, we’ll display them using the Bootstrap Carousel. The following will be features of the application:

  1. Browse and view PowerPoint (PPT/PPTX) presentations.
  2. Set the default PowerPoint file to be displayed on page load.
  3. Slider to navigate between slides.

Steps to Create PowerPoint Viewer in ASP.NET Core

The following are some easy steps to create a PowerPoint Viewer in ASP.NET Core.

1. Create a new ASP.NET Core Web Application in Visual Studio.

Create ASP.NET PowerPoint Viewer

2. Open NuGet Package Manager and install Aspose.Slides for .NET package.

ASP.NET PowerPoint Slideshow

3. Create Presentations and Slides folders in wwwroot to keep the PowerPoint files and the rendered slides respectively.

PowerPoint Slideshow in ASP.NET

4. Create a new folder with the name “Helpers” in the root folder.

5. Create a new class with the name “Slide” in the “Helpers” folder to store the presentation slides’ information.

6. Open the “HomeController.cs” and replace its code with the following (Update the default PowerPoint file’s name in Index action).

7. Open Views/Home/index.cshtml and replace its content with the following.

8. Build the application and run it in your favorite browser.

PowerPoint Viewer in ASP.NET Core

ASP.NET PowerPoint Viewer – Demo

Get a Temporary License for Aspose.Slides for .NET

You can get the temporary license of Aspose.Slides for .NET to avoid trial limitations.

Posted in Aspose.Slides Product Family | Tagged , , , | Leave a comment

Convert Word DOC/DOCX to PDF Programmatically in Java

Convert Word to PDF in Java

Word to PDF conversion is commonly used before the documents are shared. Various online Word to PDF converters are available that allow you to convert single or a limited number of Word documents. However, with emerging MS Word automation and report generation solutions, automated Word to PDF conversion has become an essential part of the systems. Furthermore, the batch conversion of DOC/DOCX to PDF needs to be done automatically to minimize the time and efforts. Keeping an eye on such scenarios, I’ll show you how to automate the process of converting Word (DOC/DOCX) documents to PDF programmatically in Java.

Word to PDF Conversion Scenarios

You’ll learn about the following Word (DOC/DOCX) to PDF conversions in this article.

  • Convert a Word document to PDF in Java.
  • Convert selected pages of a Word DOC/DOCX to PDF in Java.
  • Convert Word to PDF with a specific PDF Standard such as PDF 1.5, PDF/A-1a, etc.
  • Convert Word to PDF with image/text compression in Java.
  • Convert Word to PDF with the customized JPEG quality for images in Java.

Java Word API for Word to PDF Conversion

For converting Word documents to PDF, we’ll use Aspose.Words for Java which is a powerful Word automation API for working with popular Word document formats. You can either download Aspose.Words for Java or install it in your Maven-based application using the following configurations.

Repository

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>https://repository.aspose.com/repo/</url>
</repository>

Dependency

<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-words</artifactId>
    <version>20.1</version>
    <classifier>jdk17</classifier>
</dependency>

Convert Word (DOC/DOCX) to PDF in Java

In order to convert a Word document to PDF, Aspose.Words for Java provides save() method of the Document class. You can simply load the Word document and call this method by specifying the output file name with the “.pdf” extension.

The following code sample shows how to convert a Word DOC to PDF in Java.

Word Document

DOC DOCX to PDF in Java

PDF Document

DOC/DOCX to PDF

Convert Selected Pages of Word DOC/DOCX to PDF in Java

In case you want to convert only selective pages of Word to PDF, You can do it using the PdfSaveOptions class. You can either convert first N pages or a range of pages by specifying the starting page’s index.

The following code sample shows how to convert selected pages of Word DOC/DOCX to PDF in Java.

Convert Word DOC/DOCX to Particular PDF Standard in Java

There exist various PDF standards a PDF document may compliant with, such as PDF/A-1a, PDF 1.5, etc. In case you want to convert Word document to a specific PDF standard, you can specify it using PdfCompliance.

The following code sample shows how to convert Word DOCX to PDF with a particular PDF standard in Java.

Convert Word to PDF with Text or Image Compression in Java

You can also reduce the size of the resultant PDF document by compressing the text or image in the Word document. You can apply the following compressions in Word to PDF conversion using Aspose.Words for Java.

Text Compression Options

Aspose.Words for Java provides PdfTextCompression class with the following text compression options:

  • None: No text compression.
  • Flate: Flate (ZIP) compression.

Image Compression

The image compression options are available in the PdfImageCompression class.

  • Auto: The most appropriate compression for every image is selected automatically.
  • Jpeg: Images are converted to JPEG format (does not support transparency).

The following code sample shows how to convert Word DOCX to PDF by applying text and image compression in Java.

Convert Word to PDF with JPEG Quality in Java

You can also customize and control the JPEG quality in Word to PDF conversion. The PdfSaveOptions.setJpegQuality is used to set JPEG quality which can be from 0 (worst quality with maximum compression) to 100 (best quality with minimum compression).

The following code sample shows how to specify JPEG quality while converting Word DOCX to PDF in Java.

Try Aspose.Words for Java for Free

You can get a free temporary license to try and use Aspose.Words for Java.

Posted in Aspose.Words Product Family | Tagged , , , | Leave a comment

Read, Add, Update or Remove Slide Notes in PowerPoint Presentations using C#

read add update and remove slide notes in PowerPoint using C# .NET

Slide notes in the PowerPoint presentations are used to add references for the presenter to recall the important points during the presentation. These notes can be added to every slide of a PowerPoint presentation. This article also covers some important aspects of dealing with slide notes in presentations programmatically.

After reading this article, you will be able to:

  • read slide notes in PowerPoint presentation using C#,
  • add slide notes to a PowerPoint presentation in C#,
  • update notes in a particular slide of the PowerPoint presentation in C#, and
  • remove slide notes in a PowerPoint presentation using C#.

Working with Slide Notes using Aspose.Slides for .NET

In order to work with slide notes in PowerPoint, we’ll use Aspose.Slides for .NET – a powerful PowerPoint automation API that supports creating, updating, parsing and converting presentation documents. You can download the API or install it using the following options:

Using NuGet Package Manager

read or update slide notes in PowerPoint C# .NET

Using the Package Manager Console

PM> Install-Package Aspose.Slides.NET

Read Slide Notes from PowerPoint Presentation in C#

In order to access the slide notes in PowerPoint, Aspose.Slides for .NET provides INotesSlideManager interface. INotesSlideManager lets you access, read, add and update the slide notes. The following are the steps to read the slide notes from the PowerPoint presentation.

The following code sample shows how to read slide notes from a PowerPoint PPTX using C#.

Add Notes to a PowerPoint Slide in C#

The following are the steps to add notes to a particular slide in a PowerPoint presentation.

  • Load the PowerPoint presentation in the Presentation object.
  • Access the NotesSlideManager of particular slide.
  • Use the INotesSlide interface to add a new note.
  • Save the presentation using Presentation.Save(String, SaveFormat) method.

The following code sample shows how to add slide notes to a PowerPoint PPTX using C#.

Update Slide Notes in PowerPoint Presentation using C#

In order to update the notes in a particular presentation slide, you will access the NotesSlide in the same way you have done for reading the notes. Once you have got access to the slide notes, you can simply update the text using INotesSlide.NotesTextFrame.Text property. Once done, save the presentation file using the Presentation.Save(String, SaveFormat) method.

The following code sample shows how to update slide notes in a PowerPoint presentation using C#.

Remove Slide Notes in PowerPoint Presentation using C#

To remove the slide notes from a PowerPoint presentation, simply call INotesSlideManager.RemoveNotesSlide() method and save the presentation file. The following code sample shows how to remove slide notes from a PowerPoint presentation using C#.

Try Aspose.Slides for .NET for Free

You can try Aspose.Slides for .NET using a free temporary license.

Posted in Aspose.Slides Product Family | Tagged , , , | Leave a comment

Find and Replace Text in Excel Spreadsheets using C#

The Excel spreadsheets have minimized the efforts required to keep the huge data and perform complex calculations automatically. Excel automation was the next big achievement that has streamlined the way of creating Excel spreadsheets and performing a variety of operations on the data programmatically.

Finding and replacing text in Excel is one of the frequently performed operations in Excel automation. Therefore, in this article, I will show you how to find and replace a particular text in large Excel spreadsheets programmatically in C# with a few lines of code. Ultimately, you will learn how to:

  • Find and replace text in Excel Workbook in C#
  • Find and replace text in Excel Workbook using regular expression (Regex) in C#

API for Finding and Replacing Text in Excel Workbooks

Aspose.Cells for .NET is a powerful API that allows you to completely automate the process of creating, editing, parsing and converting the Excel spreadsheet programmatically. The API also provides easy ways of finding and replacing text based on the plain text as well as regular expressions (regex). You can either download the API or install it in your application via NuGet Package Manager or Package Manager Console.

NuGet Package Manager

Find and replace text with regex in Excel

Package Manager Console

PM> Install-Package Aspose.Cells

Find and Replace Text in Excel using C#

The following is the simple recipe to find and replace text in an Excel workbook using Aspose.Cells for .NET.

The following code sample shows how to find and replace text in Excel using C#.

Find and Replace Text with Regex in Excel using C#

You can also find and replace text that matches a particular pattern, such as Email IDs, SSN, etc. In order to do that, just set the ReplaceOptions.RegexKey property to true and call Workbook.Replace(String, String, ReplaceOptions) method.

The following code sample shows how to find and replace the text with regex in the Excel workbook.

Try Aspose.Cell for .NET for Free

Get a free temporary license of Aspose.Cells for .NET and enjoy its powerful features.

Posted in Aspose.Cells Product Family | Tagged , , | Leave a comment