> 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/viewer/pdfviewctrl.md).

# Display PDF using PDFViewCTRL in Xamarin

Learn how to display PDFs in Xamarin.iOS using PTPDFViewCtrl. Follow step-by-step instructions for adding and customizing PDFs in your app. Optimize your PDF viewing experience now! The Apryse Xamarin

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

{% hint style="info" %}
**Displaying a PDF**

The easiest way to display a PDF is using a [`PTDocumentController`](/xamarin/guides/ios/basics/open.md). The [`PTPDFViewCtrl`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.PDFViewCtrl.html) is a low-level control that may be used when a higher level of customization is required.
{% endhint %}

## About PTPDFViewCtrl

The [`PTPDFViewCtrl`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.PDFViewCtrl.html) is a `UIView` that displays a PDF.

If your app is displaying a PDF, a `PTPDFViewCtrl` will be used in one of two ways:

* Directly, by adding it as a subview to another view in your app.
* As a component piece of a [`PTDocumentController`](/xamarin/guides/ios/basics/open.md) or `PTTabbedDocumentViewController`. (It is accessible via the `pdfViewCtrl` property.)

## Use PTPDFViewCtrl as a stand-alone component

1. These instructions assume that you've [initialized Apryse](/xamarin/get-started/faq/add-license.md).
2. Add a PDF to your project:

* Right click on `Resources`
* Click on `Add` > `Add Files`
* Choose a file (in this tutorial, let's say we added a `sample.pdf`) and confirm add
* Make sure the `Build Action` of the file is set to `BundleResource`

1. Instantiate a new [`PDFDoc`](https://sdk.apryse.com/api/xamarinios/pdfnet/api/pdftron.PDF.PDFDoc.html):

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

```csharp
var pdfPath = "sample.pdf";
var docToOpen = new pdftron.PDF.PDFDoc(pdfPath);
```

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

1. Create a new [`PDFViewCtrl`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.PDFViewCtrl.html) and add it as a child to the current view:Running the app will now display the PDF `sample.pdf`. However, it will not support annotation creation, editing, text selection, or any other UI aspect that is handled by [Tools package ](/xamarin/annotation/namespaces.md#ios). To add support for annotations and text selection you need to [incorporate the tools package ](/xamarin/annotation/config-annot-tools.md#ios).

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

```csharp
// Create a new PDFViewCtrl
var pdfViewCtrl = new pdftron.PDF.PDFViewCtrl();

// Set the document to display
pdfViewCtrl.Doc = TypeConvertHelper.ConvPDFDocToNative(docToOpen);

// Add the PDFViewCtrl to the current view controller's root view.
View.AddSubview(pdfViewCtrl);

// Auto Layout
pdfViewCtrl.TranslatesAutoresizingMaskIntoConstraints = false;
NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] {
    pdfViewCtrl.LeadingAnchor.ConstraintEqualTo(this.View.LeadingAnchor),
    pdfViewCtrl.WidthAnchor.ConstraintEqualTo(this.View.WidthAnchor),
    pdfViewCtrl.TopAnchor.ConstraintEqualTo(this.View.LayoutMarginsGuide.TopAnchor),
    pdfViewCtrl.BottomAnchor.ConstraintEqualTo(this.View.BottomAnchor)
});
```

{% 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/xamarin/basic-operations/basics/viewer/pdfviewctrl.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
