Merge PDFs with the Similar name

Hello Everyone,
I have bunch of files in single folder. Now, out of those files,I will have to find a files with similar name and that would look like “Filename_invoice” and “Filename_return”. Basically I will have to find those files(PDFs). Merge them and print them. Do you think merging can be done in ignition without any external module? Let me know if anyone have done this before.
Thank you

Why would you need to merge them? The only advantage I can see is that you may save some paper by double-sided printing if any of the PDFs have an odd number of pages.

I wouldn’t think that Ignition could merge the PDFs and create a new file “Filename_merged”.

Do you think merging can be done in ignition without any external module?

I doubt it to be honest.

You have two options as I see it -

  1. Find or make an external web service that merges pdf’s for you and then use system.net.* functions to send your pdf’s over and get the merged result back.

  2. Make a python file you run via system.util.execute - could be something as simple as this - python - Merge PDF files - Stack Overflow . Note you’d need to incorporate command line arguments - probably the file paths of your pdfs either absolute or relative in some way that makes sense, and then call your file with the paths of the pdf’s you want merged when you need to do it.

If its sensetive documents, you might not want to do this, since i do not doubt they save all files and most likely harvest info from them to sell to advertisers and others.

Regarding option 1) yes that is definitely something you should be wary of, unless you make your own Flask server that can do this for yourself.

Great. Thank you for responses. I will try method 2 as it seems more secure and I have heard about PyPDF2 in past. Let me know if anyone find easier way to do it.

Thank you

The easiest way is a library like PyPDF2 i guess. just be sure to get a version that is works for python 2.7
copy pylib folder of the igntion gateway and you can import it in your scripts

Though i dont really see why you would want to do this

I didn’t mean it that way. I meant to put it in it’s own py file that you would tell the OS to run using system.execute. Will require python to be installed on your computer but this way does give you a lot more flexibility in that you don’t need it to be a jython version.

Ah yea that can too,
if there is a good version avaible, it would be easier to use that than system.util.execute tho

1 Like

Yea fair enough if its possible definitely easier to do directly. I always operate under the assumption any modern python package most likely doesn’t have a jython version and so you must shell it out or put it into it’s own little server etc.

2 Likes