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