How can I split a pdf containing multiples pages into several files? I want to split each 2 pages = 1 PDF document

How can I split a pdf containing multiples pages into several files? I want to split each 2 pages = 1 PDF document

Example here (there are 12 pages)

I want to have 6 files (so page 1 and 2 = 1 file) (page 3 and 4 = another file ) etc…

Is that possible? Which activities to be sued in order to do that?

Hey @mce ,

You can use a package from the marketplace

BalaReva.Pdf.Activities

This has a feature of PDFsplitter

Hope it helps you out

We Assume: Project Compatibility is Windows

retrieve the page count:
grafik

Create range series - myRanges
grafik

we will dynamize it with the pageCount Variable. Also can handle even/odd cases properly

Then we loop over myRanges and using the looped value here:
grafik

1 Like

@mce

In properties of extract pdf range of “Range”:(init_PageCount-1).ToString &“-”&(init_PageCount).ToString

Rigandu,

I try to use your method but I obtain the following error message

What did I do wrong?

Thanks in advance for your help.

@mce

Give the destination path as “Test”+(init_PageCount-1).ToString &“-”&(init_PageCount).ToString+“.pdf”

I still have the problem (see below)

Hi @mce ,

For the error received, it is already recorded and the fix is already mentioned :

In the UiPath.PDF.Activities package (official not third party) there is a Extract PDF Page Range. You could loop over that to split it into the pages you want.

@mce

Remove parenthesis and run the workflow

Hi @mce

Follow this YouTube video. You will find the solution for splitting the PDF’s.

Hope it helps!!

This doesnt work as well.

I have tried to build this differently and I’m almost there (I can split each 2 pages together but once splitted I have the following error message :


Do you have an idea why I obtain this error message?

variables used :

Thanks in advance for the help

@mce

Initialise intCurrentPage to 1

This is worst if I put Intcurrentpage to 1 => I still have the same error message and the output are not correctly splitted each 2 pages.

Do you have another idea?

we shared above and also show cased:

@mce

I think the error is in the while loop condition so change the comparision operator

Instead of <= give = only

This is not the solution as I can have a file with 12 pages another one with 34 pages the other one 44 etc…

In my opinion I have to keep intCurrentPage <=intTotalPageCount otherwise nothing happens if I remove the symbo < and only keep =. Do you have anothe solution ?

we mentioned that it will be dynamized with a variable. Also we used the get pdf page count activity for getting the current page count.

So we can do, using myPageCount Variable and mySegment Variable:

mySegment | Int32 = 2

Pagecount = 12 | even
grafik

PageCount = 13 | odd
grafik


So, we dont see any blocker, when working dynamic with variables as already mentioned, when presented

Can you help tell me how to create range series ?