I have a Microsoft Form that allows attachments. Power Automate is then used to attach the response and attachments and email them. I have had successful tests with docx, xls, pdf attachments, but problems arise when users attach scanned documents that output as jpeg, png etc.
The flow fails with the following error:
**Some of the files are corrupted or encrypted. Please check the following files: **
The file with index 1 is corrupted. The file with index 2 is corrupted.
The "Merge PDF" action can process only PDF-files so you have to prepare your images for merging. Below, I will show you how to create a DOCX-file with the submitted images and convert it to PDF so it could be merged with other PDF-files or saved as a separate one. The described approach can be integrated in your flow with all modifications you find necessary.
Create an array variable to store objects with images
Check whether a name of each attachment ends with an image extension (the condition is within "Apply to each" block):
If true, get file content from OneDrive by ID (all submitted attachments are stored there), compose an object with file content and append it to the array variable: