Hello, I’m new to UiPath and I’m trying to make some demo processes to show the software to my co-workers to see if it is something we can use in our environment. I’m trying to create a process that will look at all of the PDF files in a directory and then run a for each loop on each to extract a specified page. I’m getting the below compile error. I think I’m using the wrong variable type but I can’t seem to find a type that will work. Any help is appreciated.
Can you try passing ‘file’ to the “Extract PDF Page Range” activity?
Let me know if this works
Thanks for the help. I had tried that before and was getting a different compile error. I tried changing it back and got the below error. After some googling I was able to get the variable types matched up in a way that does not result in any compile errors but when I run the process it only extracts the page from one of the PDF files in the directory instead of all of them. Any ideas?
Glad it worked.
What do you have set as the ‘OutputFileName’ property?
Try changing the TypeArgument of the for loop to String:
I have had similar issues in the past and would keep forgetting to change this. Let me know how that works
I was also reading somewhere that in order to loop through PDFs, you need the paid version of UiPath. Not sure if that still is true, but maybe something to look into.
I have a file path to a non-existent PDF. I was hoping the process would create the PDF and add the extracted pages. It does create the PDF, but it only includes the PDF from the second PDF in the folder (there are only two in the folder I’m looping through).
Hmm, that’s odd, maybe that is what is going on. Thanks for your help with this. Got me closer to a working process anyway.
My guess as to what’s happening is it overwrites the previous file when adding the second page.
Could you try creating separate files with a wildcard file name and then combine them with another activity?
Thanks, this was part of the problem. After setting this and making a couple of other changes I was able to get it working kind of. Just doesn’t seem to be doing exactly what I was expecting.
I think you are right about the overwrite. Not sure how to use a wildcard file name. Do you mean change the OutputFileName path to include a wild card like the below? All that did was create a file with the wild card in the name. Is there a different way to do it?
In your For Each activity, assign the output variable:
Then in your file path it would be something like:
“C:\Users%yourUser%\Desktop\UiPathDemo\PDF\extractedpages” + %outputVariable.ToString% + “.pdf”
Dude, you’re awesome, this is working. Thanks so much for your help. I did end up having to install the PDFSharp package and the UIPathTeam.PDF.Extension.Activities to do the merge but it is working now. Below is my complete process.
Glad I was able to help
@mrice1982 glad to hear you got it working!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.