MERGE PDF FILES WITH (DYNAMIC) SIMILAR NAMES

@supermanPunch
I would greatful if you could help me with a solution.

i am new learner. i dont have much idea about VB and coding language.

I have PDF Files under root folder with different (Dynamic) names and I want to merge the PDF file based on matching case as below.

Input date is like this

Root folder : A

PDF Files in A

EQNT-23-24-001
EQNT-23-24-001a

EQNT-23-24-002
EQNT-23-24-002a

ETMH-23-24-001
ETMH-23-24-001a

ETMH-23-24-002
ETMH-23-24-002a

ETMH-23-24-003
ETMH-23-24-003a

Ouput Requirment Combine PDFs as this:

Create a new root folder as Final-Today date

Merge:
EQNT-23-24-001 + EQNT-23-24-001a as 1 file
EQNT-23-24-002 + EQNT-23-24-002a as 1 file
ETMH-23-24-001 + ETMH-23-24-001a as 1 file
ETMH-23-24-002 + ETMH-23-24-002a as 1 file
ETMH-23-24-003 + ETMH-23-24-003a as 1 file

Sequence of pages :slight_smile:

EQNT-23-24-001 should be 1st page.
EQNT-23-24-002 should be 1st page
ETMH-23-24-001 should be 1st page
ETMH-23-24-002 should be 1st page
ETMH-23-24-003 should be 1st page

Output File name should be =
EQNT-23-24-001
EQNT-23-24-002
ETMH-23-24-001
ETMH-23-24-002
ETMH-23-24-003

Hi @Techno_Freak ,

Could you provide us with bit more details on whether there would always be two files that would need merging or could there be more files associated to it as well ?

Also, Does the format of the file name always remain the same ? Four words separated by hyphen with the last word/number having only 3 characters that match?

Also, Not sure how the input date is factored here.

  1. always 2 files to merge
  2. name format will be same (only the last 3digit numbers will cahnge as per the invoice numbers)

for Eg.
EQNT-23-24-001
EQNT-23-24-001a

output: EQNT-23-24-001

last 3 digits will change as per the invoice numbers…001, 002, 003…

EQNT-23-24-XXX name before hypen should remain unchanged.

@Techno_Freak ,

We could check with the below steps :

  1. Firstly, Retrieving all the pdf files from the Input Folder, which could be done as below using an Assign activity :
AllFilePaths = Directory.GetFiles(Path.Combine(Environment.CurrentDirectory,"A"),"*.pdf").TOArray
  1. Next, Since we want to combine the files based on the file name we can Group the similar files together and store it in the form of a Dictionary (Key - Required Output File name, Value - Array of Similar Filenames)
dictSimilarFilePaths = AllFilePaths.GroupBy(Function(x)String.Join("-",Split(x,"-").Take(Split(x,"-").Count-1))+"-"+Split(x,"-").Last.Substring(0,3)).ToDictionary(Function(x)Path.GetFileName(x.First),Function(y)y.ToArray)
  1. Next, As required you can create the new Folder Name using Create Folder activity. Assign the new folder name to a variable like done below.
newFolderName = Now.ToString("dd-MM-yyyy")
  1. Next, Iterate through the created Dictionary and use the Join PDF files activity to combine the similar file paths collected. Use the New Folder name for the Output Files to be placed.
    The Property values :
FileList = currentItem.Value
OutputFileName = Path.Combine(newFolderName,currentItem.Key)

Check the steps above and let us know if you are able to perform the same.

SIR,

As i said, I am not a professinal programmer,

its difficult for me to understand the steps.

i request you to make a zip project and share.

@supermanPunch
SIR,

As i said, I am not a professinal programmer,

its difficult for me to understand the steps and palce the commands.

i request you to design make a zip project and share.

@Techno_Freak ,

Apologies for the late reply.

Check the below workflow :
PDF_Combine_BasedOnFileNames.zip (1.9 MB)

@supermanPunch
Thanks lot.
its very kind of you.
this has been very useful for me.

1 more thing i wanted to ask you. regarding the same project.

after the final stage. pdf has been made in new folder.

can it be digital signed via DSC in bulk?

all files to be digittaly signed via DSC in 1 step

@Techno_Freak ,

We would require to understand how was this process performed manually ?

We can then check if a Background Method or a Third Party Package would help you out in doing so, then perform the necessary addition to the workflow.

after the PDF have been generated in the new created DATE folder

all PDF files have to be digiitally signed with DSC usb.

i use to manually open each files and put a Digital Signature on each page manually via Adobe Acrobat. (which supports sigining 1 file at a time.) which is more time consuming.

so if its possible to sign the files automatically via some method than please do guide me.

i have tried Third Party softwares like BULK PDF Signers and all but its not working.

Signature applies on 1st page. (But not clearly Visible)

so if you can help with this. it would be great.

@Techno_Freak ,

Is it possible to provide the Signed PDF Sample ? So that we can identify if the process is similar to adding an Image at a Designated place in the PDF.