> 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/xamarin/basic-operations/basics/crop-pages.md).

# Cropping PDF pages in Xamarin

Cropping PDF pages in Xamarin is easy with the Apryse library, you can crop pages manually or automatically, as well as reset document pages to their original size. The UserCropDialogFragment allows a

{% hint style="info" %}
**This tutorial only applies to Xamarin.Android.**
{% endhint %}

With the Apryse library you can crop pages manually or automatically, as well as reset document pages to their original size. The [`UserCropDialogFragment`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Controls.UserCropDialogFragment.html) allows a user to adjust the page's crop box which can then be applied to a subset of pages or to all the pages in a document.

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-829d16c6a0dd2a2b5a4590c036eb396908a49aeb%2Fbe20e1f5d7b00edf611f9ef5a75f79ddedd90f7c-600x1200.gif?alt=media)

## Show user crop pages dialog

To show a user crop pages dialog in your activity, create a new instance of [`UserCropDialogFragment`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Controls.UserCropDialogFragment.html) by calling `newInstance()` and setting the [`PDFViewCtrl`](https://sdk.apryse.com/api/xamarinandroid/pdfnet/api/pdftron.PDF.PDFViewCtrl.html):

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

```csharp
public void ShowUserCropDialog()
{
    var userCropDialogFragment = pdftron.PDF.Controls.UserCropDialogFragment.NewInstance()
        .SetPdfViewCtrl(mPdfViewCtrl);
    userCropDialogFragment.SetStyle((int)DialogFragmentStyle.NoTitle, Resource.Style.PDFTronAppTheme);
    userCropDialogFragment.Show(this.SupportFragmentManager, "user_crop_pages_dialog");
}
```

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

In order to view user cropped pages in [`PDFViewCtrl`](https://sdk.apryse.com/api/xamarinandroid/pdfnet/api/pdftron.PDF.PDFViewCtrl.html) make sure you set `Page.e_user_crop` as the default page box:

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

```csharp
mPdfViewCtrl.SetPageBox(pdftron.PDF.Page.Box.e_user_crop);
```

{% 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/xamarin/basic-operations/basics/crop-pages.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.
