> 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/xamarin/basic-operations/basics/non-pdf.md).

# Open MS Office documents and convert to PDF in Xamarin

Learn how to display non-PDF files in Xamarin.Android using PDFViewCtrl. Convert various file types to PDF seamlessly, including Office files and images. Follow step-by-step instructions for easy impl

{% hint style="info" %}
**This tutorial only applies to Xamarin.Android. See Xamarin.iOS equivalent here .**
{% endhint %}

{% hint style="warning" %}
For Android, available in the full version of the library only. See [Apryse full or standard?](/xamarin/get-started/faq/full-vs-standard.md)
{% endhint %}

{% hint style="info" %}
Internet connection is not required for conversion.
{% endhint %}

{% hint style="info" %}
If you are already using any of [DocumentActivity](/xamarin/guides/android/basics/open.md#activity) or [PdfViewCtrlTabHostFragment2 ](/xamarin/guides/android/basics/open.md#fragment), you will not need to go through this article as viewing other document types is already taken care of internally. Continue reading this article if you are not planning to use any of the above.
{% endhint %}

{% hint style="info" %}
Saving annotations back to non-PDF formats is not supported. You can instead save the annotated PDFDoc to a PDF file.
{% endhint %}

`PDFViewCtrl` has a powerful and seamless conversion system which allows you to stream documents during conversion to PDF. It supports the following file types:

* Office file conversion: .docx, .pptx, .xlsx, .doc. (with the office conversion Add-On module)
* Image conversion: .bmp, .jpg, .tif, .png, .gif
* Image collections (zip archives with any type of image listed above)
* Markdown: .md (with the office conversion Add-On module)

In this tutorial you will be able to display a non-PDF file in `PDFViewCtrl`.

Before going forward, please make sure you have finished setting up `PDFViewCtrl` as described in [Using PDFViewCtrl](/xamarin/guides/android/basics/open.md#view).

## View a document

The easiest way to display a non-PDF file in `PDFViewCtrl` is through the `PDFViewCtrl.openNonPDFUri` API.

### Option 1: from local device storage

{% hint style="warning" %}
\*\* Storage Permission \*\*

Please follow the latest Android best practices and guidelines outlined [here](https://developer.android.com/training/permissions/usage-notes/)
{% endhint %}

Add the following when you would like to show the document, typically `onCreate` or `onResume` of your Activity or Fragment:

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

```csharp
var nonPdfUri = Android.Net.Uri.FromFile(new Java.IO.File("my_file_path"));
var documentConversion = pdfViewCtrl.OpenNonPDFUri(nonPdfUri, null);
```

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

### Option 2: from content uri

Add the following when you would like to show the document, typically `onCreate` or `onResume` of your Activity or Fragment:

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

```csharp
var nonPdfContentUri = Android.Net.Uri.Parse("my_content_uri");
var documentConversion = pdfViewCtrl.OpenNonPDFUri(nonPdfContentUri, null);
```

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

To monitor the conversion event, do:

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

```csharp
pdfViewCtrl.UniversalDocumentConversion += (sender, e) =>
{
    if (e.State == PDFViewCtrl.ConversionState.Progress)
    {
        // conversion in progress
    }
    else if (e.State == PDFViewCtrl.ConversionState.Finished)
    {
        // conversion finished successfully
    }
    else if (e.State == PDFViewCtrl.ConversionState.Failed)
    {
        // conversion failed
    }
}
```

{% 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/xamarin/basic-operations/basics/non-pdf.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.
