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

# Rect

Sample Obj-C code for using Apryse SDK to change a page's MediaBox using Rect class.

Sample Obj-C code for using Apryse SDK to change a page's MediaBox using Rect class. Learn more about our [iOS SDK](/ios/guides.md) and [PDF Editing & Manipulation Library](/core/page-manipulation/manipulation.md).

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

```objc
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2024 by Apryse Software Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.
//---------------------------------------------------------------------------------------

#import <OBJC/PDFNetOBJC.h>
#import <Foundation/Foundation.h>

int main(int argc, char *argv[])
{
    @autoreleasepool {
        int ret = 0;
        [PTPDFNet Initialize: 0];

        @try // Test  - Adjust the position of content within the page.
        {
            NSLog(@"_______________________________________________");
            NSLog(@"Opening the input pdf...");

            PTPDFDoc *input_doc = [[PTPDFDoc alloc] initWithFilepath: @"../../TestFiles/tiger.pdf"];
            [input_doc InitSecurityHandler];

            PTPageIterator *pg_itr1 = [input_doc GetPageIterator: 1];

            PTPDFRect * media_box = [[pg_itr1 Current] GetMediaBox]; 

            [media_box SetX1: [media_box GetX1] - 200]; // translate the page 200 units (1 uint = 1/72 inch)
            [media_box SetX2: [media_box GetX2] - 200];

            [media_box Update: [[PTObj alloc] init]];
        
            [input_doc SaveToFile: @"../../TestFiles/Output/tiger_shift.pdf" flags: 0];

            NSLog(@"Done. Result saved in tiger_shift...");
        }
        @catch(NSException *e)
        {
            NSLog(@"Caught PDFNet exception: %@", e.reason);
            ret = 1;
        }
        [PTPDFNet Terminate: 0];        
        return ret;
    }
}
```

{% endcode %}
{% endtab %}

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

```swift
//---------------------------------------------------------------------------------------
// Copyright (c) 2001-2019 by PDFTron Systems Inc. All Rights Reserved.
// Consult legal.txt regarding legal and license information.
//---------------------------------------------------------------------------------------

import PDFNet
import Foundation

func runRectTest() -> Int {
    return autoreleasepool {
        var ret: Int = 0
        
        
        do {
            try PTPDFNet.catchException {
                // Test  - Adjust the position of content within the page.
                print("_______________________________________________")
                print("Opening the input pdf...")
                
                let input_doc: PTPDFDoc = PTPDFDoc(filepath: Bundle.main.path(forResource: "tiger", ofType: "pdf"))
                input_doc.initSecurityHandler()
                
                let pg_itr1: PTPageIterator = input_doc.getPageIterator(1)
                
                let media_box: PTPDFRect = pg_itr1.current().getMediaBox()
                
                media_box.setX1(media_box.getX1() - 200) // translate the page 200 units (1 uint = 1/72 inch)
                media_box.setX2(media_box.getX2() - 200)
                
                media_box.update(PTObj())
                
                input_doc.save(toFile: URL(fileURLWithPath: NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]).appendingPathComponent("tiger_shift.pdf").path, flags: 0)
                
                print("Done. Result saved in tiger_shift...")
            }
        } catch let e as NSError {
            print("Caught PDFNet exception: \(e)")
            ret = 1
        }
        
        return ret
    }
}
```

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


---

# 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/samples/recttest.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.
