I'm trying to figure out if I can create a PowerShell script that lets me combine multiple PDF files into a single document. My work computer is pretty limited, and I can't use Python or install any new software, which makes things tricky. What I want to achieve is having the script:
1. Search within a specific directory.
2. Merge PDFs named "1a-document.pdf", "1b-document.pdf", and "1c-document.pdf" into one massive PDF. I also need to combine "2a-document.pdf", "2b-document.pdf", and "2c-document.pdf" together, and do the same for other groups like "3a-document.pdf", "3b-document.pdf", and so on.
3. The script should automatically recognize which PDFs belong to which group to prevent mixing them up. So, can PowerShell pull this off?
4 Answers
Have you checked out PDFtk-Server? It's a command-line tool that integrates nicely with PowerShell. You can build commands in your PowerShell script to use it without having to really dive deep into coding.
PowerShell doesn’t natively support merging PDFs. You'd need an external module to handle PDF processing. If you can't install Python or any other software, you may have a tough time, as loading external PowerShell modules might break your Terms of Service at work.
PowerShell can indeed run without admin permissions for basic tasks, and you typically don't need much to execute scripts. However, as mentioned, you'll probably have to bring in a third-party module to do the PDF merging, which may require admin rights. Just for the record, does your workplace not provide Adobe Acrobat? It’s a pretty handy tool for PDFs and isn’t too pricey.
PowerShell doesn’t directly handle PDF merging as part of its built-in features. You might consider libraries such as iText7 for more advanced needs, or check out the PSWritePDF module, although it seems to be outdated. Either way, it's a good way for you to learn and tinker with scripts!
What do you mean by needing an "external module"? How does that work?