Articles in this section
Category / Section

How to convert Word document to PDF in UWP

3 mins read

Syncfusion Essential DocIO Renderer is a .NET Core Word to PDF conversion library allows you to convert Word document to PDF in UWP application [C#].

Steps to convert Word document to PDF programmatically in UWP:

  1. Create a new C# Blank App (Universal Windows) project.
    Create UWP application in Visual Studio
  2. Install the Syncfusion.DocIORenderer.NET.Core NuGet package as a reference to your UWP application from

Add DocIO NuGet package reference to the project

  1. Add a new button in the MainPage.xaml as shown below.


    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Button x:Name="button" Content="Generate PDF" Click="OnButtonClicked" HorizontalAlignment="Center" VerticalAlignment="Center"/>
  1. Include the following namespaces in the Mainpage.xaml.cs file.


using Syncfusion.DocIO.DLS;
using Syncfusion.DocIORenderer;
using Syncfusion.Pdf;


  1. Include the below code snippet in the click event of the button in MainPage.xaml.cs, to convert a Word document to PDF and save the PDF document as a physical file and open the file for viewing.


private async void OnButtonClicked(object sender, RoutedEventArgs e)
    //Creates an instance of WordDocument Instance (Empty Word Document)
    WordDocument wordDocument = new WordDocument();
    //Add a section and a paragraph in the empty document
    //Append text to the last paragraph of the document
    wordDocument.LastParagraph.Text = "Adventure Works Cycles, the fictitious company on which the" +
" AdventureWorks sample databases are based, is a large, multinational manufacturing company. ";
    //Instantiation of DocIORenderer for Word to PDF conversion
    DocIORenderer render = new DocIORenderer();
    //Converts Word document into PDF document
    PdfDocument pdfDocument = render.ConvertToPDF(wordDocument);
    //Releases all resources used by the Word document and DocIO Renderer objects
    //Saves the PDF file
    MemoryStream outputStream = new MemoryStream();
    //Closes the instance of PDF document object
    outputStream.Position = 0;
    //Save the PDF file
private async void SavePDF(Stream outputStream)
    StorageFile stFile;
    if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons")))
      FileSavePicker savePicker = new FileSavePicker();
      savePicker.DefaultFileExtension = ".pdf";
      savePicker.SuggestedFileName = "Sample";
      savePicker.FileTypeChoices.Add("Adobe PDF Document", new List<string>() { ".pdf" });
      stFile = await savePicker.PickSaveFileAsync();
      StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
stFile = await local.CreateFileAsync("Sample.pdf", CreationCollisionOption.ReplaceExisting);
    if (stFile != null)
      Windows.Storage.Streams.IRandomAccessStream fileStream = await stFile.OpenAsync(FileAccessMode.ReadWrite);
      Stream st = fileStream.AsStreamForWrite();
      st.Write((outputStream as MemoryStream).ToArray(), 0, (int)outputStream.Length);
      MessageDialog msgDialog = new MessageDialog("Do you want to view the Document?", "File created.");
      UICommand yesCmd = new UICommand("Yes");
      UICommand noCmd = new UICommand("No");
      IUICommand cmd = await msgDialog.ShowAsync();
      if (cmd == yesCmd)
          // Launch the retrieved file
          bool success = await Windows.System.Launcher.LaunchFileAsync(stFile);


A complete working example of how to convert Word document to PDF in UWP using .NET Core Word to PDF conversion library can be downloaded from Word to PDF in

Take a moment to peruse the documentation, where you can find basic Word document processing options along with features like mail merge, merge and split documents, find and replace text in the Word document and protect the Word documents with code examples.

Explore more about the rich set of Syncfusion Word Framework features.

See Also:

Create Word document in UWP

Mail merge Word document in UWP

  1. As per MSDN announcement, the minimum version of UWP project must be Fall Creators Update (FCU).
  2. Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.


Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied