> 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/get-started/viewdoc.md).

# View a document using PTDocumentController

Learn how to use the Legacy Viewer for PTDocumentViewController class in iOS development. Follow step-by-step instructions to integrate PDFNet and Tools libraries, override viewDidAppear() method, and

{% hint style="info" %}
**Legacy Viewer**

For the legacy `PTDocumentViewController` class, please see [this guide ](/ios/get-started/get-started/viewdoc-legacy.md).
{% endhint %}

1. Open your ViewController file. This is either the `ViewController.swift` or `ViewController.m` file in the left pane depending on your choice of language. Import PDFNet and Tools libraries.

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

```swift
import PDFNet
import Tools
```

{% endcode %}
{% endtab %}

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

```objc
#import <PDFNet/PDFNet.h>
#import <Tools/Tools.h>
```

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

1. Override the `viewDidAppear()` method in the `ViewController` class and then open the DocumentViewController using:

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

```swift
override func viewDidAppear(_ animated: Bool) {
    // Create a PTDocumentController
    let documentController = PTDocumentController()
    // The PTDocumentController must be in a navigation controller before a document can be opened
    let navigationController = UINavigationController(rootViewController: documentController)
    navigationController.modalPresentationStyle = .fullScreen
    navigationController.navigationBar.isTranslucent = false
    navigationController.toolbar.isTranslucent = false
    // Open a file from URL.
    let fileURL: URL = URL(string:"https://pdftron.s3.amazonaws.com/downloads/pl/sample.pdf")!
    documentController.openDocument(with: fileURL)
    // Show navigation (and document) controller.
    self.present(navigationController, animated: true, completion: nil)
}
```

{% endcode %}
{% endtab %}

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

```objc
- (void)viewDidAppear:(BOOL)animated {
    // Create a PTDocumentController
    PTDocumentController *documentController = [[PTDocumentController alloc] init];
    // The PTDocumentController must be in a navigation controller before a document can be opened
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:documentController];
    navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
    navigationController.navigationBar.translucent = NO;
    navigationController.toolbar.translucent = NO;
    // Open a file from URL.
    NSURL *fileURL = [[NSURL alloc] initWithString:@"https://pdftron.s3.amazonaws.com/downloads/pl/sample.pdf"];
    [documentController openDocumentWithURL:fileURL];
    // Show navigation (and document) controller.
    [self presentViewController:navigationController animated:YES completion:nil];
}
```

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

1. Click on the white play button on the top left of your window to launch the application in the Simulator.

Your app should look like this:

![](https://4149080208-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgY6xtY9ZQd9XMpvWlGM0%2Fuploads%2Fgit-blob-12d54f459f4b62ff2a22800a73e7cabe0da026f6%2F4a19165cb4fbe1a72c8e991d05d83e2afde1425b-761x1649.png?alt=media)

## Next step

<a href="/ios/get-started/customize.md" class="button primary">Customize</a>


---

# 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/get-started/viewdoc.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.
