> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/uwp/ms-office/convert-office.md).

# Convert MS Office (Word, Excel, PowerPoint) to PDF in UWP

Convert MS Office files to PDF with ease using our comprehensive guide. Learn how to convert Word, Excel, and PowerPoint files to PDF format seamlessly. Find out about font resources, substitute fonts

To convert an MS Office file to a PDF document without any external third party dependencies.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Start with a PDFDoc (the conversion destination)
PDFDoc doc = new PDFDoc();

// perform the conversion with no optional parameters
Convert.OfficeToPDF(doc, filename, null);
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Convert MS Office files to PDF](/uwp/get-started/samples.md#officetopdf) Full sample code which illustrates how to convert MS Office files (Word, Excel, PowerPoint) to PDF.

## Additional font resources

The converter will attempt to make use of any fonts installed on the system. Fonts (or alternatives) can also be provided as described below.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
PDFNet.Initialize();

// if fonts.json is at /home/user/webfonts/fonts.json
// this can also be an https URL
WebFontDownloader.SetCustomWebFontURL("file:///home/user/webfonts/");

// allow PDFNet to access the network to download missing fonts when possible.
WebFontDownloader.EnableDownloads();
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Self serving substitute fonts faq](/web/get-started/faq/self-serve-substitute-fonts.md) A more detailed faq guide about creating substitute web fonts set when a font is not embedded in the document or available on the system.

[Self serve font package](https://pdftron.s3.amazonaws.com/downloads/SelfServeWebFontsV2.zip) A curated package of fonts with great coverage of widely used font files. Simply extract and pass the path to the API above.

### User-provided .docx resource document (optional)

The converter can produce good results with no user-supplied fonts at all, but for the highest conversion quality, fonts can be provided in a .docx resource document. This document must be named `pdftron_convert_resources.docx` and can reside in either in the resource directory (use PDFNet.AddResourceSearchPath() to set this value), or at some arbitrary location, specified in the conversion options (set via OfficeToPDFOptions.SetResourceDocPath()). The file should have all the required fonts embedded within it (you can create a file like this by checking the "embed fonts in the file" option from the "Save" preferences within Word )

### Apryse-provided fallback font data (required)

If no appropriate fonts are found on the system or in a resource .docx, then the converter will need to use it's own fallback font data. On desktop/server, this data is built into the library and will be automatically used. On mobile, the data is not part of the binary, but is included in the SDK package as a separate resource file: `pdftron_layout_resources.plugin`. This file can either be placed in the resource directory (set via PDFNet.AddResourceSearchPath()), or in some arbitrary location, specified in the conversion options.

## Font embedding

When the conversion routine is able to find a matching font, it will embed that font in the resulting PDF. Otherwise, the converter will attempt to embed one of the PDF base 14 fonts if there is a close enough match, and failing that, will not embed the font at all.

## Smart embedding

Using pdftron-supplied smart substitution data, the conversion routine can produce PDF documents with fully embedded fonts that are a close match to the originals. To enable this option, either place the file `pdftron_smart_substitution.plugin` (included in the SDK download) in the resource directory (set via PDFNet.AddResourceSearchPath()), or specify it's path directly in the conversion options.

{% tabs %}
{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// Start with a PDFDoc (the conversion destination)
using (PDFDoc pdfdoc = new PDFDoc())
{
  OfficeToPDFOptions options = new OfficeToPDFOptions();
  options.SetSmartSubstitutionPluginPath(input_path);
  // create a conversion object -- this sets things up but does not yet
  // perform any conversion logic.
  // in a multithreaded environment, this object can be used to monitor
  // the conversion progress and potentially cancel it as well
  DocumentConversion conversion = pdftron.PDF.Convert.StreamingPDFConversion(pdfdoc, input_path + input_filename, options);

  // actually perform the conversion
  // this particular method will not throw on conversion failure, but will
  // return an error status instead
  if (conversion.TryConvert() == DocumentConversionResult.e_document_conversion_success)
  {
    // save the result
    pdfdoc.Save(output_path + output_filename, SDFDoc.SaveOptions.e_linearized);
  }
}
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/uwp/ms-office/convert-office.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
