Read PDF Text Activity - Range Parameter - Use of Variables

Hello UiPath Support,
I have a scenario where I have several hundred PDFs of varying total page count. I need only read the first page, second to last page and last page. I am attempting to use the Read PDF Text activity and getting error with Range parameter.

  • varLastPage is a string variable and is output from Get PDF Page Count activity (converted Int32 to string)
  • varSecondToLastPage is a string variable and is calculated from varLastPage - 1

I am attempting to provide the following into Range Parameter - “1,varLastPage,varSecondToLastPage” however I run into format error.

QUESTION: How are string variables to be passed into the Range Parameter of Read PDF Text Activity?

@DARREN_THOMPSON

If you converted Int32 to String then if you want to make -1 to the count which is a string then write as below

Cint(varLastPage-1).Tostring

Hope this will help you

Thanks

That is helpful thank you very much! As for the QUESTION at hand do you have thoughts?

let’s have a pdf with 10 pages we would assume following Range string:
“1,2-9,10” which we can construct with following
String.Format(“{0},{1},{2}”, var1, var2, var3)

however the result would be the same as reading all pages with the “All” range string

@DARREN_THOMPSON

If you are trying to read 1st to end of the page and you need to pass that in the Range?

If that is the case you can leave the string as “All” only

Thanks

I like where you may be going with this…I need pages 1, 9, 10

not sure if I got you. However you can do following:

  • thest it with a particular pdf and hardcoded range string
  • test it with String.Format(“{0},{1},{2}”, “1”, (intPageCountVar-1).toString, intPageCountVar.toString)
1 Like

Thank you very much! This works like a champ!

Perfect. so the topic can be closed?
Forum FAQ - How to mark a post as a solution - News / Tutorials - UiPath Community Forum

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.