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 126.96.36.199) 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.
- Images (PNG, JPEG, BMP and GIF).
- Headers and footers.
- 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.
- Windows 10 (recommended)
- Visual Studio 2015 or Visual Studio 2017 (recommended)
- Windows 10 SDK
- OS X El Capitan (10.11) or newer
- Visual Studio for Mac
- iOS 10 SDK and Xcode 8
1. Create a Cross-Platform App (Xamarin.Forms) and name it WordtoPDFdemo.
2. Select the Blank App template and the .NET Standard option under Code Sharing Strategy.
3. Right-click the .NET Standard project, select Properties, and set the Target framework of the application as .NET Standard 1.4 or higher.
4. Add the Syncfusion.Xamarin.DocIORenderer NuGet package as a reference to the .NET Standard project in your Xamarin application.
Note: Syncfusion Xamarin components are available on nuget.org.
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.
<!--?xml version="1.0" encoding="utf-8" ?--> <contentpage x_class="WordToPDF.MainPage"> <stacklayout padding="10"> <label x_name="Content_heading" text="Word to PDF in XForms" fontsize="Large" fontattributes="Bold" horizontaloptions="Center" verticaloptions="Center"></label> <label x_name="Content_1" text="This sample demonstrates how to convert a Word Document to PDF using DocIORenderer." fontsize="Medium" verticaloptions="Center"></label> <button x_name="btnGenerate" clicked="OnButtonClicked" text="Convert to PDF" horizontaloptions="Center" verticaloptions="Center" tabindex="151"></button> </stacklayout> </contentpage>