I have a process where the user specifies the pages to extract and the system cycles through PDFs in a folder and creates a new PDF using the Extract PDF Page Range activity. Eg the user supplies “1,3” and the system then processes through a 6 page document and will extract the 2 pages into a new document.
The issue I have is that the number of pages may vary and an error is thrown if the number specified by the user is greater than the number of pages. E.g user specifies “1,3,5,7” however it is only a 4 page document.
I can determine the PDF page count via the Get PDF Page Count activity and I want to compare the pages specified by the user which are comma separated and get all numbers less than or equal to the actual Page count.
Absolutely! There are multiple ways, but I’d suggest the following one:
1- As you said use the “Get PDF Page Count” to get the nomber of pages.
2- Convert your comma-separated string into array of pages such as {1,3,5,7}
3- apply LINQ to filter out all the pages in the array, higher than the max value on “Get PDF Page Count”
P.S. If this assign removes any page from the user input, I’d say it’s a good practice to log that you are removing a few pages, else you might get a question from the business about the bot not following their “input”