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

# View a PDF document on Server/Desktop

Discover how to use the PDF Viewer Control in a basic project with full source code. Implement document navigation, text highlighting, markup, and editing effortlessly.  The Apryse Server SDK streamli

{% hint style="warning" %}
For Server or Desktop-based applications, this is only available on Microsoft Windows.
{% endhint %}

To view a PDF document.

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

```csharp
// create a view controller
PDFViewCtrl view = new PDFViewCtrl();

// create a doc instance
PDFDoc doc = new PDFDoc(filename);

// set doc to the view
view.SetDoc(doc);
```

{% endcode %}
{% endtab %}

{% tab title="C++" %}
{% code lineNumbers="true" %}

```cpp
// define pointer for view controller
std::auto_ptr<PDF::PDFViewCtrl> view;

// create a view controller,
// passing in the platform specific window handle and the current HINSTANCE for windows
view = std::auto_ptr<pdftron::PDF::PDFViewCtrl>(new pdftron::PDF::PDFViewCtrl(parent_hwnd, hinstance));

// create a doc instance
std::auto_ptr<PDF::PDFDoc> doc(new PDF::PDFDoc(filename));

// set doc to the view
view->SetDoc(*doc);
```

{% endcode %}
{% endtab %}

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

```java
// create a view controller
PDFViewCtrl view = new PDFViewCtrl();

// create a doc instance
PDFDoc doc = new PDFDoc(filename);

// set doc to the view
view.setDoc(doc);
```

{% endcode %}
{% endtab %}

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

```js
// first initialize the viewer
WebViewer({
  path: '../../../lib',
  initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf'
}, document.getElementById('viewer'))
.then(instance => {
  // load the PDF from URL, Blob, Filesystem or Base64 data
  instance.loadDocument(e.target.value);
});
```

{% endcode %}
{% endtab %}

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

```objc
// create a view controller
PTPDFViewCtrl* view = [[PTPDFViewCtrl alloc] init];

// create a doc instance
PTPDFDoc* doc = [[PTPDFDoc alloc] initWithFilepath:filename];

// set doc to the view
[view SetDoc:doc];
```

{% endcode %}
{% endtab %}

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

```swift
// create a view controller
let view: PTPDFViewCtrl = PTPDFViewCtrl()

// create a doc instance
let new_doc: PTPDFDoc = PTPDFDoc(filename)

// set doc to the view
view.setDoc(doc)
```

{% endcode %}
{% endtab %}

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

```php
// create a view controller
$view = new PDFView();

// create a doc instance
$doc = new PDFDoc($filename);

// set doc to the view
$view->SetDoc($doc);
```

{% endcode %}
{% endtab %}

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

```ruby
# create a view controller
view = PDFView.new()

# create a doc instance
doc = PDFDoc.new(filename)

# set doc to the view
view.SetDoc(doc)
```

{% endcode %}
{% endtab %}

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

```vb
' create a view controller
Dim view As PDFViewCtrl = New PDFViewCtrl()

' create a doc instance
Dim doc As PDFDoc = New PDFDoc(filename)

' set doc to the view
view.SetDoc(doc)
```

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

[PDF Viewer Control (Simple) sample - Full sample](/core/get-started/samples/pdfviewsimpletest.md) Full source code which shows how to use PDF viewer control in a basic project. The sample uses a number of built-in features from PDFViewCtrl to implement document navigation, text highlighting, markup, and editing. Samples available in Python, C# (.Net), C++, Go, Java, Node.js (JavaScript), PHP, Ruby, VB. To use this code, you'll need to [download and get started with Server SDK](/core/get-started/get-started.md).

## About viewing a document

The Apryse SDK comes with a powerful high level class called `PDFViewCtrl` that allows users to easily display PDF documents in their application. This class wraps around all the document processing lower level details that are required when displaying a PDF document.


---

# 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/core/viewer/viewing.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.
