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

# Convert between different coordinates on Server/Desktop

Convert PDF coordinates with ease using PDFViewCtrl. Learn how PDF page, screen, and scrolling coordinates work and how to navigate them effectively. Master the art of coordinate systems for precise P

`PDFViewCtrl` allows you to convert from one coordinate system to another with ease.

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

```csharp
PDFViewCtrl view = new PDFViewCtrl();
PDFDoc doc = new PDFDoc(filename);
view.SetDoc(doc);

int page = 1;
double x = 0, y = 0;

// Converts a point in a page space to a point in screen space.
view.ConvPagePtToScreenPt( ref x, ref y, page);

// Converts a point in screen space to a point in a page space.
view.ConvScreenPtToPagePt( ref x, ref y, page);
```

{% endcode %}
{% endtab %}

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

```cpp
std::auto_ptr<PDF::PDFViewCtrl> view;
view = std::auto_ptr<pdftron::PDF::PDFViewCtrl>(new pdftron::PDF::PDFViewCtrl(parent_hwnd, hinstance));
std::auto_ptr<PDF::PDFDoc> doc(new PDF::PDFDoc(filename));
view->SetDoc(*doc);

int page = 1;
double x = 0, y = 0;

// Converts a point in a page space to a point in screen space.
view->ConvPagePtToScreenPt(x, y, page);

// Converts a point in screen space to a point in a page space.
view->ConvScreenPtToPagePt(x, y, page);
```

{% endcode %}
{% endtab %}

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

```java
PDFViewCtrl view = new PDFViewCtrl();
PDFDoc doc = new PDFDoc(filename);
view.setDoc(doc);

int page = 1;
double x = 0, y = 0;

// Converts a point in a page space to a point in screen space.
Point2D.Double screenpt = view.convPagePtToScreenPt(x, y, page);

// Converts a point in screen space to a point in a page space.
Point2D.Double pagept = view.convScreenPtToPagePt(x, y, page);
```

{% endcode %}
{% endtab %}

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

```objc
PTPDFViewCtrl* view = [[PTPDFViewCtrl alloc] init];
PTPDFDoc* doc = [[PTPDFDoc alloc] initWithFilepath:filename];
[view SetDoc:doc];

int page = 1;
double x = 0, y = 0;

// Converts a point in a page space to a point in screen space.
PTPDFPoint* screenpt = [view ConvPagePtToScreenPt: [[PTPDFPoint alloc] initWithPx: x py: y] page_num: page];

// Converts a point in screen space to a point in a page space.
PTPDFPoint* pagept = [view ConvScreenPtToPagePt: [[PTPDFPoint alloc] initWithPx: x py: y] page_num: page];
```

{% endcode %}
{% endtab %}

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

```swift
let view: PTPDFViewCtrl = PTPDFViewCtrl()
let new_doc: PTPDFDoc = PTPDFDoc(filename)
view.setDoc(doc)

var x = 0
var y = 0
var page = 1

// Converts a point in a page space to a point in screen space.
let screenpt: PTPDFPoint = view.convPagePt(toScreenPt: PTPDFPoint(px: x, py: y), page_num: page)

// Converts a point in screen space to a point in a page space.
let pagept: PTPDFPoint = view.convScreenPt(toPagePt: PTPDFPoint(px: x, py: y), page_num: page)
```

{% endcode %}
{% endtab %}

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

```php
$view = new PDFView();
$doc = new PDFDoc($filename);
$view->SetDoc($doc);

$x = 0;
$y = 0;
$page = 1;

// Converts a point in a page space to a point in screen space.
$screenpt = $view->ConvPagePtToScreenPt(new Point($x, $y), $page);

// Converts a point in screen space to a point in a page space.
$pagept = $view->ConvScreenPtToPagePt(new Point($x, $y), $page);
```

{% endcode %}
{% endtab %}

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

```python
view = PDFView()
doc = PDFDoc(filename)
view.SetDoc(doc)

x = 0
y = 0
page = 1

# Converts a point in a page space to a point in screen space.
screenpt = view.ConvPagePtToScreenPt(Point(x, y), page)

# Converts a point in screen space to a point in a page space.
pagept = view.ConvScreenPtToPagePt(Point(x, y), page)
```

{% endcode %}
{% endtab %}

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

```ruby
view = PDFView.new()
doc = PDFDoc.new(filename)
view.SetDoc(doc)

x = 0
y = 0
page = 1

# Converts a point in a page space to a point in screen space.
screenpt = view.ConvPagePtToScreenPt(Point.new(x, y), page)

# Converts a point in screen space to a point in a page space.
pagept = view.ConvScreenPtToPagePt(Point.new(x, y), page)
```

{% endcode %}
{% endtab %}

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

```vb
Dim view As PDFViewCtrl = New PDFViewCtrl()
Dim doc As PDFDoc = New PDFDoc(filename)
view.SetDoc(doc)

Dim page = 1
Dim x = 0, y = 0

' Converts a point in a page space to a point in screen space.
view.ConvPagePtToScreenPt(x, y, page)

' Converts a point in screen space to a point in a page space.
view.ConvScreenPtToPagePt(x, y, page)
```

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

## Understanding coordinates

PDF documents have their own coordinate system, which is different from the screen coordinate system of the viewer. For instance, when asking for the position of an annotation element in a PDF document using the Apryse API, the position is given in PDF page coordinates instead of screen coordinates.

Here is an example of a screen capture and table of [PDF page coordinates](https://docs.apryse.com), [screen coordinates](https://docs.apryse.com), and [scrolling coordinates](https://docs.apryse.com)

![](https://3779731113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fziw3GiL98Xfj63F3He8h%2Fuploads%2Fgit-blob-124b41e0b5391ee89797a950a46563207c54ba7b%2F81f5c51a983a7b21749208d8c732b9ffde5b1873-346x429.png?alt=media)

| Coordinates           | x1     | y1     | x2     | y2    |
| --------------------- | ------ | ------ | ------ | ----- |
| PDF page coordinates  | 62.8   | 165.3  | 538.4  | 415.5 |
| Screen coordinates    | 62.0   | 1368.6 | 1023.9 | 862.5 |
| Scrolling coordinates | 5063.0 | 1368.6 | 6024.9 | 862.5 |

## PDF page coordinates

In a PDF document, the location origin (0, 0) is at the bottom left corner of the PDF page. The x axis is positive horizontally to the right and y axis is positive vertically upward. A page location point represents a point in page coordinates. Page points by default is 1⁄72 inch. So an 8.5 x 11 inch page would be 612 x 792 points.

![](https://3779731113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fziw3GiL98Xfj63F3He8h%2Fuploads%2Fgit-blob-5862ad044b4bce1bd75a9b2af9ef1df1fc8b42a1%2F3fa71527edc9e2e815358fbbe536b935b06f6922-328x420.png?alt=media)

A PDF page can have a rotation associated with it. In this case, the location origin (0, 0) may no longer correspond to the bottom left corner of the page.

For example, here is the page above rotated 90 degrees clockwise. Notice how the location origin (0, 0) is now at the top left corner of the viewport.

![](https://3779731113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fziw3GiL98Xfj63F3He8h%2Fuploads%2Fgit-blob-1e1e800fef90429fee9c3ba3775a753753b9a8f6%2F07b3b3fed37ecbbcd0992920a3ed401c0901f669-415x322.png?alt=media)

## Screen coordinates

In the `PDFViewCtrl` class, the location points of the viewer are measured in screen coordinates. Location origin (0, 0) is at the top left corner of the viewport. The x axis is positive horizontally to the right and the y axis is positive vertically downward. A screen location point represents a point in screen coordinates.

![](https://3779731113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fziw3GiL98Xfj63F3He8h%2Fuploads%2Fgit-blob-f412d5d959557a33cee59f7d656b9c1b3d2bbb66%2F7affd8c039177e0223ad0b2509849b78b3f512b0-324x408.png?alt=media)

Since screen coordinates align to the viewer, if `PDFViewCtrl` zooms in, then an element's screen coordinates may change.

For example, here are two screen captures of the same annotation element before and after zooming in, and a table showing how its screen coordinates change.

![](https://3779731113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fziw3GiL98Xfj63F3He8h%2Fuploads%2Fgit-blob-b7ade883f17747f5b3085e3d2786bea1d973d046%2F493d754212e80051b0a795b4112d2218b55ca7e0-974x528.png?alt=media)

|                | left (x1) | bottom (y1) | right (x2) | top (y2) |
| -------------- | --------- | ----------- | ---------- | -------- |
| Before zoom in | 215.8     | 1148.8      | 805.8      | 734.6    |
| After zoom in  | 2.4       | 1130.0      | 986.8      | 638.8    |

## Scrolling coordinates

With `PDFViewCtrl`, users can flip pages horizontally or vertically. For scrolling coordinates, the location origin (0, 0) is located at the top left corner of the viewer in page 1. The x axis is positive horizontally to the right and the y axis is positive vertically downward.

![](https://3779731113-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fziw3GiL98Xfj63F3He8h%2Fuploads%2Fgit-blob-991ccb67d30a574530965833d836a4c680640f3c%2F9f717f70ecde93e31e20620f7dd43099a3da7a01-1024x608.png?alt=media)


---

# 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/coordinates.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.
