Sorting a pdf file on the basis of page number

I am having 45 pdf files each consisting of single page only and the common pattern which occurs on them is that department 11 is written on each file and some page number is also written on each file for example if I open a ramdom pdf it will definately have ‘Department11’ and say pageno. 9 wriiten onit , if I again open another pdf it will also have “department11” and say pageno 12 written on it.The problem is when I am applying “join pdf file” activity the merged pdf of 45 pages which I am getting is not in sorted manner of pageno. i.e resulting pdf when opened is showing department11 and pageno5 on page1 of merged pdf file of 45 page, similarly the second page is showing pageno.9 written on it and say third page is showing pageno2 , In all the merged pdf file which I am getting is unsorted. How can I get with a sorted pdf of 45 pages i.e first page of pdf should also be first page of Department11 and similarly second page of pdf should be 2nd page of department11 and so on and so forth. Kindly help!.. if any other clearity on question is required please feel free to ask.

Hi @shayantestingbot,

A possible solution would be

  1. Read PDF Text activity to store the contents of the file
  2. Matches activity test for pageno and extract the number 9 from pageno9
  3. Store into sorted dictionary of type Int32, String where Int32 is the pageno and String is your PDF filename
  4. Convert the sorted dictionary to array of files
  5. Join PDF Files activity

Note: we only test for pageno, the assumption that all pdf files have Department11. Pdf files are stored in same folder as UiPath script. Pdf file without pageno will not be merged.
Main.xaml (9.6 KB)