First Steps
In this getting started guide, we create a simple application that uses the Telerik Document Processing libraries to create a DOCX document and then export it as a PDF file.
The Telerik Document Processing libraries that we use in this guide are UI-independent and cover all .NET technologies, from desktop and web to mobile. They can also be deployed in client, server-side and cloud apps.
Step 1: Installing on Your Computer
Since we distribute Telerik Document Processing libraries as an addition to several Telerik UI component bundles, chances are that the libraries are already installed on your system. In this case, all you need is to locate them. The table below provides links to the installation instructions for each of the Telerik UI component suites that give you access to the Telerik Document Processing libraries. If the standard installation of your Telerik UI component suite includes the Document Processing assemblies, the table also shows their default location.
Regardless of the Telerik UI components suite that you use, you can always get the Document Processing assemblies as NuGet packages from the Telerik NuGet server.
The old https://nuget.telerik.com/nuget server is deprecated and we encourage our clients to switch to the v3 API. The new v3 API is faster, lighter, and reduces the number of requests from NuGet clients. The NuGet v2 server at https://nuget.telerik.com/nuget will be sunset in November 2024. The new v3 protocol offers faster package searches and restores, improved security, and more reliable infrastructure. To redirect your feed to the NuGet v3 protocol, all you have to do is to change your NuGet package source URL to https://nuget.telerik.com/v3/index.json.
UI Components suite | Installation instructions | Default location of the Document Processing assemblies |
---|---|---|
UI for ASP.NET AJAX | Installing Telerik UI for ASP.NET AJAX |
|
UI for ASP.NET MVC | Installing Telerik UI for ASP.NET MVC |
|
UI for ASP.NET Core | Installing Telerik UI for ASP.NET Core | The Telerik Document Processing libraries are available as NuGet packages on the Telerik NuGet server: https://nuget.telerik.com/v3/index.json. |
UI for Blazor | Installing Telerik UI for Blazor | The Telerik Document Processing libraries are available as NuGet packages on the Telerik NuGet server: https://nuget.telerik.com/v3/index.json. |
UI for WPF | Installing Telerik UI for WPF |
|
UI for Silverlight | Installing Telerik UI for Silverlight |
|
UI for WinForms | Installing Telerik UI for WinForms |
|
UI for Xamarin | Installing Telerik UI for Xamarin | [installation_path]\Binaries\Portable |
UI for WinUI | Installing Telerik UI for WinUI | C:\Program Files (x86)\Progress\Telerik UI for WinUI [version]\DPL |
UI for .NET MAUI | Installing Telerik UI for .NET MAUI | [installation_path]/Binaries/Shared |
Step 2: Creating Application with Visual Studio
As we are going to create a UI-Independent example, we will use a console project for this guide:
- Open Microsoft Visual Studio and create a new console project. It could be a .NET Framework, .NET Standard, .NET 5 or later project.
Figure 1: Go to File > New > Project > Console App (.Net Framework) > Next > Create
Step 3: Add a Telerik Document Processing Library to a Project
This sample application will use RadWordsProcessing. In this step, we must add the required assemblies.
-
Reference the assemblies that provide the RadWordsProcessing functionality:
For .NET Framework project:
- Telerik.Windows.Documents.Core.dll
- Telerik.Windows.Documents.Flow.dll
- Telerik.Windows.Zip.dll
For .NET Core/.NET 5+ project:
- Telerik.Documents.Core.dll
- Telerik.Documents.Flow.dll
- Telerik.Zip.dll
-
Reference the assembly that allows you to export the content as a PDF file:
For .NET Framework project:
- Telerik.Windows.Documents.Flow.FormatProviders.Pdf.dll
For .NET Core/.NET 5+ project:
- Telerik.Documents.Flow.FormatProviders.Pdf.dll
The Document Processing assemblies for .NET 5+ don't contain "Windows" in their names.
Step 4: Create a Document
Example 1: Create RadFlowDocument
Telerik.Windows.Documents.Flow.Model.RadFlowDocument document = new Telerik.Windows.Documents.Flow.Model.RadFlowDocument();
Telerik.Windows.Documents.Flow.Model.Editing.RadFlowDocumentEditor editor = new Telerik.Windows.Documents.Flow.Model.Editing.RadFlowDocumentEditor(document);
editor.InsertText("Hello world!");
Dim document As Telerik.Windows.Documents.Flow.Model.RadFlowDocument = New Telerik.Windows.Documents.Flow.Model.RadFlowDocument()
Dim editor As Telerik.Windows.Documents.Flow.Model.Editing.RadFlowDocumentEditor = New Telerik.Windows.Documents.Flow.Model.Editing.RadFlowDocumentEditor(document)
editor.InsertText("Hello world!")
Step 5: Export the Generated Document
Export the RadFlowDocument to DOCX
To export the document as a docx file, use DocxFormatProvider. Using the below code will create a provider instance and save a document with it. The document will be exported in the bin folder of your current project.
Example 2: Export RadFlowDocument to DOCX
using (Stream output = new FileStream("output.docx", FileMode.OpenOrCreate))
{
Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider docxProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider();
docxProvider.Export(document, output);
}
Using output As Stream = New FileStream("output.docx", FileMode.OpenOrCreate)
Dim docxProvider As Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider = New Telerik.Windows.Documents.Flow.FormatProviders.Docx.DocxFormatProvider()
docxProvider.Export(document, output)
End Using
Export the RadFlowDocument to PDF
To export the document as a PDF file, use PdfFormatProvider. Example 3 shows how to export the RadFlowDocument created in Examples 1 to a file.
Example 3: Export RadFlowDocument to PDF
using (Stream output = File.OpenWrite("Output.pdf"))
{
Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider flowPdfProvider = new Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider();
flowPdfProvider.Export(document, output);
}
Using output As Stream = File.OpenWrite("Output.pdf")
Dim flowPdfProvider As Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider = New Telerik.Windows.Documents.Flow.FormatProviders.Pdf.PdfFormatProvider()
flowPdfProvider.Export(document, output)
End Using
Run the project and you should see something like this:
Figure 2: The final result
Next Steps
Now that you have run your first project example with Telerik Document Processing Libraries, you may want to explore some additional features like clone, edit, merge, insert documents and more. Below you can find guidance on getting started with such tasks: