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

# Access PDF pages to add, copy, delete or rearrange in UWP

Learn how to efficiently manage PDF pages with code samples for copying, deleting, and rearranging pages. Access a PDF page sequence and optimize your document operations. The Apryse uwp SDK streamlin

To access a PDF page.

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

```csharp
PDFDoc doc = new PDFDoc(filename);

// Access a PDF page
Page page = doc.GetPage(page_num);
```

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

[Merge, copy, delete, and rearrange PDF pages](/uwp/get-started/samples.md#pdfpage) Full code sample which illustrates how to copy pages from one document to another, how to delete, and rearrange pages and how to use ImportPages() method for very efficient copy and merge operations.

## About working with pages

A high-level PDF document contains a sequence of Page objects, as illustrated in the following figure:

![](https://3246663708-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Frgmys2szYV2Z567Zu3vi%2Fuploads%2Fgit-blob-ac189ed4a6c6c0b49e973d38c30f51c543a85a33%2F53146f7976a63f3be37adb38823899c1f02acc1a-394x193.gif?alt=media)

PDFDoc Page sequence.

To find the number of pages in a PDF document, call `PDFDoc.GetPageCount()`.

To retrieve a specific page of a document, use `PDFDoc.GetPage(page_num)`. Page numbers in the document's page sequence are indexed from 1. If the given page number doesn't index a page in the current document, `GetPage(page_num)` returns null. For example:

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

```csharp
Page page = doc.GetPage(page_num);
if (page != null)
{
  Console.WriteLine("Document does contain page#: {0}", page_num);
}
else
{
  Console.WriteLine("Document does not contain page#: {0}", page_num);
}
```

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

While `GetPage(i)` is convenient for retrieving an individual page, it's an inefficient way to enumerate every page of a document. It's better to traverse the pages with a PageIterator.

To do so, simply call `PDFDoc.GetPageIterator()`. This returns a PageIterator object, which provides `HasNext()`, `Next()` and `Current()` methods. The following code snippet shows how to print the page size for every page in document page sequence:

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

```csharp
for (PageIterator itr=doc.GetPageIterator(); itr.HasNext(); itr.Next())
{
  Rect mediabox = itr.Current().GetMediaBox();
  Console.WriteLine("Media box: {0}, {1}, {2}, {3}", mediabox.x1, mediabox.y1, mediabox.x2, mediabox.y2);
}
```

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

(This code finds the page size using the page's media box, which we'll talk more about in the following sections.)

To jump to a specific page with a PageIterator, call `PDFDoc.GetPageIterator(page_num)`. If no such page exists, the index of the page will return 0. For example:

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

```csharp
PageIterator itr = doc.GetPageIterator(page_num);
if (itr.GetPageNumber() > 0)
{
  Console.WriteLine("Document does contain page#: {0}", page_num);
}
else
{
  Console.WriteLine("Document does not contain page#: {0}", page_num);
}
```

{% 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/basic-operations/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.
