Split PDF every 2 pages

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?

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):

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

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

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

get the number of Segments NoOfSegments = Cint(Math.Ceiling(29/2))
grafik

Create an array with Access Pairs:

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


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

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

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

Try this one…
SplitDocument.xaml (10.0 KB)

And in case you don’t have the pdf activities… these dependencies were used.
image

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

Variables:
grafik

Flow:

Starter help:
PDFSplit_2PagesRange.xaml (7.9 KB)