Getting Started with Winnovative PDF Next for .NET on Windows

Winnovative PDF Next for .NET is a library that can be integrated into any type of .NET application to create and process PDF documents.

You can create PDF documents, convert HTML, Word, Excel, RTF and Markdown documents to PDF, extract text and images from existing PDF documents, perform text search operations on PDF documents and convert PDF pages to images.

Compatibility

Winnovative PDF Next for .NET runs natively on 64-bit Windows operating systems. The product runtime is compatible with Windows 10, Windows Server 2016 and later versions of the Windows 64-bit OS.

The .NET library targets .NET Standard 2.0 and therefore can be used in any .NET Core or .NET Framework application that supports this standard.

The product can run on Windows without installing anything and without any prior configuration of the operating system. The steps required to use the library in your application are detailed below.

The software is fully compatible with Azure App Service and Azure Functions on Windows. Installation instructions for these platforms are provided in separate documentation sections.

Install NuGet Package

The library structure is modular, with separate NuGet packages for major components to prevent unnecessary files from being included in your applications. You can choose to reference a single package to install all the components of the library or you can install only the components you need.

Install the Metapackage for All Components

To install all components of the Winnovative PDF Next library, add a reference to the Winnovative.Pdf.Next.Windows metapackage from NuGet.

The metapackage references the packages for all library components, including the HTML to PDF converter, Word to PDF, Excel to PDF, RTF to PDF and Markdown to PDF conversion components, as well as the PDF text extraction and text search functionalities, the PDF to Image converter and the PDF Images Extractor. This can bring many files into your project and you may prefer to use only specific components.

Install Specific Packages for Components

To install only specific components of the Winnovative PDF Next library, you can add references to the corresponding NuGet packages from NuGet.

To use only the Core component, you can install the Winnovative.Pdf.Next.Core.Windows NuGet package.

To use only the HTML to PDF Converter component, you can install the Winnovative.Pdf.Next.HtmlToPdf.Windows NuGet package.

To use the Word to PDF, Excel to PDF, RTF to PDF or Markdown to PDF conversion components, install the corresponding package: Winnovative.Pdf.Next.WordToPdf.Windows, Winnovative.Pdf.Next.ExcelToPdf.Windows, Winnovative.Pdf.Next.RtfToPdf.Windows or Winnovative.Pdf.Next.MarkdownToPdf.Windows .

To use the PDF Processor components PDF to Text, PDF Text Search, PDF to Image and PDF Images Extraction, you only need to install the Winnovative.Pdf.Next.PdfProcessor.Windows NuGet package.

Any combination of these packages can be installed in your project, depending on which components you want to use.

Include Winnovative.Pdf.Next Namespace

All components of the library share the same Winnovative.Pdf.Next namespace and can be used together in the same application.

After the NuGet package has been installed, add the using Winnovative.Pdf.Next; directive at the top of your C# source file to include the Winnovative.Pdf.Next namespace and make the library API available.

C#
// add this using statement at the top of your C# file
using Winnovative.Pdf.Next;

You are now ready to use the Winnovative PDF Next library API in your .NET application targeting the Windows operating system.

Convert an HTML string to PDF

With the code below, you can convert an HTML string to a PDF document in a memory buffer and then save the data from the buffer to a file.

C#
// create the converter object where you want to perform the conversion
HtmlToPdfConverter converter = new HtmlToPdfConverter();

// convert an HTML string to a memory buffer
byte[] htmlToPdfBuffer = converter.ConvertHtml("<b>Hello World</b> from Winnovative !", null);

// write the memory buffer to a PDF file
System.IO.File.WriteAllBytes("HtmlToMemory.pdf", htmlToPdfBuffer);

Convert a URL to PDF

With the code below, you can convert a URL to a PDF document in a memory buffer and then save the the data from the buffer to a file. The URL can also be a local file path prefixed with the "file://" URI scheme.

C#
// create the converter object where you want to perform the conversion
HtmlToPdfConverter converter = new HtmlToPdfConverter();

// convert a URL to a memory buffer
string htmlPageURL = "http://www.winnovative-software.com";
byte[] urlToPdfBuffer = converter.ConvertUrl(htmlPageURL);

// write the memory buffer to a PDF file
System.IO.File.WriteAllBytes("UrlToMemory.pdf", urlToPdfBuffer);

Convert an HTML string to PDF in ASP.NET

With the code below, you can convert an HTML string to a PDF document in an ASP.NET Core application, store it in a memory buffer and then send it to the browser for download.

C#
// create the converter object where you want to perform the conversion
HtmlToPdfConverter converter = new HtmlToPdfConverter();

// convert an HTML string to a memory buffer
byte[] htmlToPdfBuffer = converter.ConvertHtml("<b>Hello World</b> from Winnovative !", null);

FileResult fileResult = new FileContentResult(htmlToPdfBuffer, "application/pdf");
fileResult.FileDownloadName = "HtmlToPdf.pdf";
return fileResult;

Convert a URL to PDF in ASP.NET

With the code below, you can convert a URL to a PDF document in an ASP.NET Core application, store it in a memory buffer and then send it to the browser for download. The URL can also be a local file path prefixed with the "file://" URI scheme.

C#
// create the converter object where you want to perform the conversion
HtmlToPdfConverter converter = new HtmlToPdfConverter();

// convert a URL to a memory buffer
string htmlPageURL = "http://www.winnovative-software.com";
byte[] urlToPdfBuffer = converter.ConvertUrl(htmlPageURL);

FileResult fileResult = new FileContentResult(urlToPdfBuffer, "application/pdf");
fileResult.FileDownloadName = "UrlToPdf.pdf";
return fileResult;

Run Application

At this point, everything should be configured and you can now run your application. Alternatively, you can follow the same instructions in this document to build and publish the ASP.NET demo application on Windows.

See Also