Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
View this page
Toggle table of contents sidebar
Find #mupdf on Discord
Do you have any feedback on this page?

# The MuPDF Coordinate System

## Origin Point, Point Size and Y-Axis

In PDF, the origin (for example: `(0, 0)`) of a page is located at its bottom-left point. In MuPDF, the origin of a page is located at its top-left point.

Note

The exact x,y coordinate space for origin may not be `0,0` and is defined by “CropBox” - thus “bottom left” is derived from what is defined there.

Important

The rotation of the page affects the PDF coordinate space orientation.

### Point Size

Coordinates are float numbers and measured in points, where:

- The default is one point equals 1/72 inches.

- Is defined by the “UserUnit” property.

### Positioning objects

When working with positioning objects, we should appreciate this coordinate system.

For example:

    let rectangle = [0,0,200,200]

Results in:

### Coordinate space and `PDFObject`

In exception to using the MuPDF coordinate space, if we are dealing directly with `PDFObject` streams then we are using the PDF coordinate space.

Therefore if we doing something low-level like adding a content stream to a `PDFObject`, for example:

    var extra_contents = document.addStream("q 200 0 0 200 10 10 cm /Image1 Do Q", null)

Then in this case we are working in the PDF coordinate space with the origin Y-axis at the bottom left.

Note

To explain the syntax behind `"q 200 0 0 200 10 10 cm /Image1 Do Q"` this is Adobe PDF syntax for referencing, sizing and positioning an image and can be explained as follows:

    q                               % Save graphics state
        200 0 0 200 10 10 cm        % Translate
        /Image1 Do                  % Paintimage
    Q                               % Restore graphics state

For more see page 337 of the Adobe PDF Reference Guide.

Do you have any feedback on this page?

This software is provided AS-IS with no warranty, either express or implied. This software is distributed under license and may not be copied, modified or distributed except as expressly authorized under the terms of that license. Refer to licensing information at artifex.com or contact Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, CA 94129, USA, for further information.