> 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/get-started/viewdoc-legacy.md). Agents can also search and read this documentation through its [MCP server](https://docs.apryse.com/~gitbook/mcp).

# View a document using PTDocumentViewController

Learn how to optimize your legacy PDFTron Viewer with the PTDocumentViewController class. Upgrade to PTDocumentController for the best viewing experience and new features. Follow this guide for a seam

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

This guide is for the legacy `PTDocumentViewController` class. This class is no longer being updated. For the best viewing experience and to take advantage of new developments, the `PTDocumentController` should be used. Please see [this guide](https://docs.apryse.com/ios/get-started/viewdoc.md) for information.
{% 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 PTDocumentViewController
    let documentController = PTDocumentViewController()
    // The PTDocumentViewController must be in a navigation controller before a document can be opened
    let navigationController = UINavigationController(rootViewController: documentController)
    navigationController.modalPresentationStyle = .fullScreen
    // 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 PTDocumentViewController
    PTDocumentViewController *documentController = [[PTDocumentViewController alloc] init];
    // The PTDocumentViewController must be in a navigation controller before a document can be opened
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:documentController];
    navigationController.modalPresentationStyle = UIModalPresentationFullScreen;
    // 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-5f41741c119f6e734abc3c06255e0dbe499d64cc%2Ff61a1284859e6e55c64711dfbe73db8d26954f81-749x1649.png?alt=media)

## Next step

<a href="https://docs.apryse.com/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 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/ios/get-started/get-started/viewdoc-legacy.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.
