# Split PDF every 2 pages

**URL:** <https://forum.uipath.com/t/split-pdf-every-2-pages/559063>\
**Category:** Activities\
**Tags:** pdf, activities\
**Created:** [June 29, 2023, 1:42pm UTC](https://forum.uipath.com/t/split-pdf-every-2-pages/559063 "2023-06-29T13:42:28Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gemma\_Walker](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gemma_walker/32/367955_2.png) [@Gemma\_Walker](https://forum.uipath.com/u/Gemma_Walker)\
**Post date:** [June 29, 2023, 1:42pm UTC](https://forum.uipath.com/t/split-pdf-every-2-pages/559063/1 "2023-06-29T13:42:29Z")

</div>

Hello

I have made a simple robot to split a PDF every page, but I need it to split every 2 pages, How could I do this?

---

<div class="post-metadata">

**Author:** ![Irene](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/irene/32/272962_2.png) [@Irene](https://forum.uipath.com/u/Irene)\
**Post date:** [June 29, 2023, 1:54pm UTC](https://forum.uipath.com/t/split-pdf-every-2-pages/559063/2 "2023-06-29T13:54:54Z")

</div>

Hi,  
you can use create a loop, and inside the loop you can put one Extract PDF Page Range activity, where you increment the range (min-max) by two each time ( **instead of by one** ).  
You exit the loop when you reached the total number of pages of the PDF file.

Here’s more details (but in your case you have to increment the counters by 2):

> [@How to split pdf pages and extract?](https://forum.uipath.com/t/how-to-split-pdf-pages-and-extract/167490/4):
>
> @krishnareddy Hello, I can suggest you a generalized solution. 1.) Initialize a variable counter=1 (default value) 2.) Use “Get Pdf Page Count” and in properties section you will see PageCount: declare a variable of type integer in that column of say name “totalPages”, now with the help of this variable you can easily know the number of pages in any given pdf file. 3.)Now use a while scope and set condition as (counter \<= totalPages). 3.1)Within the scope of while use “ExtractPdfPageRange”…

---

<div class="post-metadata">

**Author:** ![Gemma\_Walker](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gemma_walker/32/367955_2.png) [@Gemma\_Walker](https://forum.uipath.com/u/Gemma_Walker)\
**Post date:** [June 29, 2023, 3:37pm UTC](https://forum.uipath.com/t/split-pdf-every-2-pages/559063/3 "2023-06-29T15:37:19Z")

</div>

thank you for the reply, I did try this but then it is only saving every second page  
Maybe I didnt write it clearly

I have a 28 page pdf

What I am trying to acheive is 1 file with pages 1-2. another file with pages 3-4 etch  
The pdf may have a different even number of pages each time

---

<div class="post-metadata">

**Author:** ![Irene](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/irene/32/272962_2.png) [@Irene](https://forum.uipath.com/u/Irene)\
**Post date:** [June 29, 2023, 4:14pm UTC](https://forum.uipath.com/t/split-pdf-every-2-pages/559063/4 "2023-06-29T16:14:11Z")

</div>

Could you share your xaml sequence, so I can take a look at it?

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [June 29, 2023, 4:20pm UTC](https://forum.uipath.com/t/split-pdf-every-2-pages/559063/5 "2023-06-29T16:20:46Z")

</div>

With the Get PDF Count Activity it can be grabbed how many Pages are in the document - docCount

Then we can create an array with the extract page pairs (also handling even / odd cases)

get a series with page numbers: arrPageNos = Enumerable.Range(1,29).ToArray  
 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/e/8/a/e8a0af748aca70c2040b05bf4a4d2b2d31b7e08e.png)

get the number of Segments NoOfSegments = Cint(Math.Ceiling(29/2))  
 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/4/d/4/4d427ad0cfcea234b1d4e515100e1297869b7ac2.png)

Create an array with Access Pairs:

```auto
arrRanges = Enumerable.Range(0,NoOfSegments).Select(Function (x) String.Join("-", arrPageNos.Skip(x*2).Take(2))).toArray

```

 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/7/a/5/7a5e07ea5c0cb8e6235792c11a7c84b2a837c531.png)  
 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/1/d/a/1daf55a096e1074aaeccf2eef5f0922d07364708.png)

Then loop over range Array with a for each and use the Extract PDF Range Activity for the extraction. The looped range info will be used for the Range property of the Extract PDF Range

---

<div class="post-metadata">

**Author:** ![Gemma\_Walker](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gemma_walker/32/367955_2.png) [@Gemma\_Walker](https://forum.uipath.com/u/Gemma_Walker)\
**Post date:** [June 29, 2023, 6:40pm UTC](https://forum.uipath.com/t/split-pdf-every-2-pages/559063/6 "2023-06-29T18:40:17Z")

</div>

thank you for this, im not sure what you mean by the looped range inf will be used for the range property of the extract pdf range

Do you have a xaml example I could look at? Id really appreciate it

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [June 29, 2023, 6:44pm UTC](https://forum.uipath.com/t/split-pdf-every-2-pages/559063/7 "2023-06-29T18:44:01Z")

</div>

When using a for each Activity | item in arrRanges |TypeArgument set to String

- log message: item

Then you would see  
1-2  
3-4  
5-6  
…

Just try it as you are close to have got it done

---

<div class="post-metadata">

**Author:** ![Jeroen\_van\_Loon](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/jeroen_van_loon/32/61520_2.png) [@Jeroen\_van\_Loon](https://forum.uipath.com/u/Jeroen_van_Loon)\
**Post date:** [June 29, 2023, 7:08pm UTC](https://forum.uipath.com/t/split-pdf-every-2-pages/559063/8 "2023-06-29T19:08:35Z")

</div>

Try this one…  
[SplitDocument.xaml](https://forum.uipath.com/uploads/short-url/dy4rZh1eh56BGZoWTs5S75U4X1L.xaml) (10.0 KB)

And in case you don’t have the pdf activities… these dependencies were used.  
 ![image](https://global.discourse-cdn.com/uipath/original/4X/8/d/f/8df8463eaaf775c5ab9c38b056a3dcaf88fca8f1.png)

---

<div class="post-metadata">

**Author:** ![Gemma\_Walker](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/gemma_walker/32/367955_2.png) [@Gemma\_Walker](https://forum.uipath.com/u/Gemma_Walker)\
**Post date:** [June 30, 2023, 8:16am UTC](https://forum.uipath.com/t/split-pdf-every-2-pages/559063/9 "2023-06-30T08:16:41Z")

</div>

thank you so much, that works a treat and it makes sense now that I see it 🙂

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [June 30, 2023, 8:51am UTC](https://forum.uipath.com/t/split-pdf-every-2-pages/559063/10 "2023-06-30T08:51:35Z")

</div>

> [@Gemma\_Walker](#):
>
> Do you have a xaml example I could look at?

Variables:  
 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/f/3/1/f313ca6df4200cfa92669cd0d1f1da960c913d5c.png)

Flow:

 ![grafik](https://global.discourse-cdn.com/uipath/original/4X/c/5/a/c5add3965f221831c91205539c61b467f167c8f9.png)

Starter help:  
[PDFSplit\_2PagesRange.xaml](https://forum.uipath.com/uploads/short-url/hPYO6kryKWFf00Z7xkhLUSxFrqt.xaml) (7.9 KB)

---

<div class="post-metadata">

**Author:** ![ppr](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ppr/32/464097_2.png) [@ppr](https://forum.uipath.com/u/ppr)\
**Post date:** [March 11, 2026, 11:40am UTC](https://forum.uipath.com/t/split-pdf-every-2-pages/559063/12 "2026-03-11T11:40:19Z")

</div>

Closed on March 11, 2026, 11:40am UTC


