> 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/ios/basic-operations/basics/viewer/pdfviewctrl.md).

# Display PDF using PDFViewCTRL on iOS

Learn how to display a PDF using PTPDFViewCtrl and PTDocumentController. Follow step-by-step instructions for integrating PTPDFViewCtrl into your iOS app for seamless PDF viewing. The Apryse iOS SDK s

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

The easiest way to display a PDF is using a [`PTDocumentController`](/ios/basic-operations/open/doc-view.md). The [`PTPDFViewCtrl`](https://sdk.apryse.com/api/ios/Classes/PTPDFViewCtrl.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/ios/Classes/PTPDFViewCtrl.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`](/ios/basic-operations/open/doc-view.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](/ios/learn-more/initialize.md).
2. Add a PDF to your project, by dragging it into the project's left side panel. Ensure that it will be copied into the bundle's resources by checking that it is listed under the Copy Bundle Resources section of the project's Build Phases. (If it is not present here, add it using the '+' button.)The file `sample.pdf` has been added to the project, and will be copied into the bundle.

![](https://4149080208-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgY6xtY9ZQd9XMpvWlGM0%2Fuploads%2Fgit-blob-58c47e49ee48983b0fca41aaf61fb87554b96361%2Fbede1a65778f653e8d6d048f0434b6119eda5af8-1920x1308.png?alt=media)

1. Instantiate a new [`PTPDFDoc`](https://sdk.apryse.com/api/ios/Classes/PTPDFDoc.html):

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

```objc
// Get the path to document in the app bundle.
NSString* pdfPath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"pdf"];
    
// Instantiate a new PDFDoc with the path to the file.
PTPDFDoc* docToOpen = [[PTPDFDoc alloc] initWithFilepath:pdfPath];
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
// Get the path to document in the app bundle.
let pdfPath: String? = Bundle.main.path(forResource: "sample", ofType: "pdf")
    
// Instantiate a new PDFDoc with the path to the file.
let docToOpen = PTPDFDoc(filepath: pdfPath)
```

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

1. Create a new [`PTPDFViewCtrl`](https://sdk.apryse.com/api/ios/Classes/PTPDFViewCtrl.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.framework ](/ios/annotation/overview.md). To add support for annotations and text selection you need to [incorporate the tools framework ](/ios/ui-customization/setup.md).

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

```objc
// Create a new PDFViewCtrl
PTPDFViewCtrl* pdfViewCtrl = [[PTPDFViewCtrl alloc] init];

// Set the document to display
[pdfViewCtrl SetDoc:docToOpen];

// Add the PDFViewCtrl to the current view controller's root view.
[self.view addSubview:pdfViewCtrl];
  
// Set the size of the PDFViewCtrl to that of its superview.
// (Auto Layout is fully supported as well)
pdfViewCtrl.frame = self.view.bounds;
pdfViewCtrl.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
```

{% endcode %}
{% endtab %}

{% tab title="Swift" %}
{% code lineNumbers="true" %}

```swift
// Create a new PDFViewCtrl.
let pdfViewCtrl = PTPDFViewCtrl()

// Set the document to display.
pdfViewCtrl.setDoc(docToOpen)

// Add the PDFViewCtrl to the current view controller's root view.
self.view.addSubview(pdfViewCtrl)

// Set the size of the PDFViewCtrl to that of its superview.
// (Auto Layout is fully supported as well)
pdfViewCtrl.frame = self.view.bounds
pdfViewCtrl.autoresizingMask = [.flexibleWidth, .flexibleHeight]
```

{% 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/ios/basic-operations/basics/viewer/pdfviewctrl.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.
