Word to PDF conversion in Xamarin and .NET Core

Syncfusion is excited to share that Word-to-PDF conversion is now available in Xamarin and .NET Core platforms.

Cross-platform development is the future of mobile, desktop, and web application development. It provides benefits like quick deployment, lower costs, wider reach, and quick turnaround time. The adoption of cross-platform application development is increasing among enterprises and small businesses as well. The Xamarin and .NET Core platforms are being used by large numbers of developers to develop applications that target multiple platforms.

Syncfusion already provided the ability to convert Word documents to PDF in Windows Forms, WPF, ASP.NET, and ASP.NET MVC applications, but it was not extended to Xamarin and .NET Core due to the lack of a graphical API.

From the 2018 Volume 1 release (version 16.1.0.24) onwards, Syncfusion has extended the support for converting Word documents to PDF in Xamarin and .NET Core with the help of the SkiaSharp graphics library.

An illustration of the Word-to-PDF conversion process in .NET Core and Xamarin.

Currently, the following features are available in Word-to-PDF conversion:

Text with formatting.

Table.

Images (PNG, JPEG, BMP and GIF).

Headers and footers.

Hyperlinks.

Fields like page number, date time, IF, and more.

Form fields and content control.

Textbox and Shapes.

Text wrapping for floating images, textbox, and shapes.

Footnote and endnote.

Line numbering.

Bookmark navigation.

Converting Word to PDF in Xamarin

Let’s learn how to convert a Word document to PDF in the Xamarin platform.

Prerequisites

For Windows

Windows 10 (recommended)

Visual Studio 2015 or Visual Studio 2017 (recommended)

Windows 10 SDK

For macOS

OS X El Capitan (10.11) or newer

Visual Studio for Mac

iOS 10 SDK and Xcode 8

Procedure

1.Create a Cross-Platform App (Xamarin.Forms) and name it WordtoPDFdemo.

5.Add the input Word document to the asset folder in the .NET Standard project. Right-click the Word document, select Properties, and set its build action as Embedded resource.

6.Add a button in the MainPage.xaml file.

7. Add the following code in the onButtonClicked method in the MainPage.xaml.cs file. Use the ConvertToPDF method of the DocIORenderer class to convert the WordDocument instance to a PdfDocument instance and save the PDF document to the device.