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

# Rect

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

Sample C# code for using Apryse SDK to change a page's MediaBox using Rect class. Learn more about our [UWP SDK](/core/get-started/frameworks/dotnet.md) and [PDF Editing & Manipulation Library](/core/page-manipulation/manipulation.md).

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

```csharp
//
// Copyright (c) 2001-2020 by PDFTron Systems Inc. All Rights Reserved.
//

using System;
using System.IO;
using System.Threading.Tasks;
using Windows.Foundation;

using pdftron.PDF;

using PDFNetUniversalSamples.ViewModels;

namespace PDFNetSamples
{
    public sealed class RectTest : Sample
    {
        public RectTest() :
            base("Rect", "Shows how to change Page's MediaBox using Rect class.")
        {
        }

        public override IAsyncAction RunAsync()
        {
            return Task.Run(new System.Action(async () => {
                WriteLine("--------------------------------");
                WriteLine("Starting Rect Test...");
                WriteLine("--------------------------------\n");
                
                string input_file_path = Path.Combine(InputPath, "tiger.pdf");
                WriteLine("Opening input file " + input_file_path);

			    try // Test  - Adjust the position of content within the page.
			    {
				    PDFDoc input_doc = new PDFDoc(input_file_path);
				    input_doc.InitSecurityHandler();

				    pdftron.PDF.Page pg = input_doc.GetPage(1);
				    pdftron.PDF.Rect media_box = pg.GetMediaBox();

				    media_box.x1 -= 200;	// translate the page 200 units (1 UInt = 1/72 inch)
				    media_box.x2 -= 200;

				    media_box.Update();

                    String output_file_path = Path.Combine(OutputPath, "tiger_shift.pdf");
                    await input_doc.SaveAsync(output_file_path, 0);
                    input_doc.Destroy();

                    WriteLine("Done. Results saved in " + output_file_path);
                    await AddFileToOutputList(output_file_path).ConfigureAwait(false);
			    }
			    catch (Exception e)
			    {
				    WriteLine(GetExceptionMessage(e));
                }

                WriteLine("\n--------------------------------");
                WriteLine("Done Rect Test.");
                WriteLine("--------------------------------\n");
            })).AsAsyncAction();
		}
	}
}
```

{% 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 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/uwp/get-started/samples/recttest.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.
