Saving and Joining PDF files

Hello,

I have a workflow that captures screenshots from a web application. I click on “print” then save it as PDF. Now, I need to save over ~20 screens merge them in one and save as Merge1, then move on to the next account and do the same.

the problem is that I have a “for each row” to read off an excel file that user uploads as a trigger file. The BOT performs as needed however, once Merge1 is saved and moves to next account it combines all account screens into 1 merged file.

So far I have the “Move file” activity and a “delay” so the BOT can save the 1st set of screens for the account however, when its saved it saving it as a “File” and not a PDF.

image

I am not sure if Move file is the right option for this, so I am willing to try a new way if available.

Hello Arturo,

you should put the CStr(PDF) before the “.pdf” in the To, something like:
"H:\UiPath\ER_Studio\RPA 496\NF"+CStr(PDF)+".pdf"

Also, if you’re using the for each row you can use the count functionality in the properties to use a counter as you’re doing with the PDF variable, so it’s not necessary to increase it but it count automatically the iteration.

Let me know if it works.

Regards,
Stefano

1 Like

hi @stefano_negro thanks for taking the time to review my request. That Absolutely worked perfect.

for reference: Screenshot 1-2 is one account and 3-4 is another account

With that said

I have a new issue that arised. when NF1 is merged and BOT starts on the new account (NF2 i.e New File 2 PDF)its bringing in NF1 pdfs and combining them with NF2 and the final Output is a combination of all 4 screenshot 1-4 and the 2 for the account totaling 6 pages in total.

How do I avoid bringing the 1st two files i.e FN1 onto NF2 and so forth… Any ideas?

image

By looking just at the screenshot of the flow I’m assuming that you are using Join PDF on the MergePDF variable, correct?
In that case you are always using the same directory (from Directory.GetFiles in the Assign), so the files are added during the iteration.
A more clean way to do this is to create a new subfolder in the for each (eg. H:…\1, H:…\2\ and so on) and using that folder to store the screenshot, create the joined PDF and finally move it to the parent folder H:…\RPA 496
Alernatively you can delete all files from the folder at the end of the iteration, after storing the NF1.pdf in a new folder.

ok so If I can use the delete files “screenshots” after it has merged them.

I am using the following: Trying have the BOT locate anything labeled “screenshots” as a * wildcard, however I get invalid characters in path. I dont believe I have the code written correctly

basically, before moving to the next account delete all pdf named “screenshots” and move to the next account

image

Unfortunately the wildcard doesn’t work on the delete, you have to loop trough the files in the folder (using Directory.Get Files before) and delete the ones you don’t need.

I think that a more simple solution would be to do this inside the For Each:

  1. Create a Folder inside RPA 496 (eg. H:\UiPath\ER_Studio\RPA 496\File 1)
  2. Put every screenshot.pdf file inside it
  3. Join PDF Files in the new file H:\UiPath\ER_Studio\RPA 496\File 1\Merged1.pdf
  4. Move the Merged1.pdf into the RPA 496 folder (from H:\UiPath\ER_Studio\RPA 496\File 1\ to H:\UiPath\ER_Studio\RPA 496)
  5. Delete the folder H:\UiPath\ER_Studio\RPA 496\File 1\
1 Like

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