How to Fix Power Automate Creating Corrupted PDF Files in SharePoint
Question details
Users experience corrupted or invalid PDF files when using a Power Automate flow to upload or create documents in a SharePoint folder.

- Product
- Power Automate and SharePoint
- Device & OS
- not provided
- Scenario
- A user is running a Power Automate flow that automatically creates a new SharePoint folder and attempts to upload a PDF file into it.
- Observed behavior
- The resulting uploaded PDF file either lacks the correct '.pdf' extension or has invalid, corrupt content, making it impossible to open or read in a PDF viewer.
Check your Power Automate flow run history to verify that the source file is not empty or corrupted before it reaches the SharePoint upload action.
Configure Compose Actions for Correct File Name and ContentBytes
Use specific Compose actions to accurately extract the file name with its extension and the binary content bytes, preventing data corruption during file creation.
Many PDF corruption issues in Power Automate stem from the 'Create file' action receiving base64 encoded strings instead of raw binary data, or missing the explicit file extension in the name property.
In your flow, add a 'Compose' action before the SharePoint step. Use an expression like string(triggerBody()?['file_1']?['name']) to capture the exact file name. Ensure this output includes the '.pdf' extension.
Add a second 'Compose' action to capture the raw binary data. Use an expression such as string(triggerBody()?['file_1']?['contentBytes']) to ensure the file contents are formatted correctly for SharePoint.
In the SharePoint 'Create file' action, map the 'File Name' field to the output of your first Compose action, and map the 'File Content' field to the output of your second Compose action.

Use a Staging Document Library and Copy Action
If direct file creation in a newly generated folder remains unreliable, upload the file to an established document library first, then copy it to the destination.
Manage and Verify PDF Documents Easily with WPS Office
While troubleshooting automated workflows in SharePoint, you may need a reliable desktop tool to open, verify, or edit PDF files. WPS Office offers a comprehensive, free alternative for handling PDFs and all standard office document formats seamlessly.
- 1. Download and Install WPS Office: Get the free WPS Office suite from the official website and install it on your computer.
- 2. Open the downloaded SharePoint PDF: Launch WPS PDF, click 'Open', and select the downloaded file from your SharePoint library to check its integrity.
- 3. Edit or Convert as needed: Use the built-in PDF tools to repair formatting, add annotations, or convert the document to Word format if necessary.

Frequently Asked Questions
Why do my PDFs created by Power Automate have no file extension?
This happens when the file name variable passed to the SharePoint 'Create file' action does not explicitly include the '.pdf' string at the end. You must ensure the dynamic content or manual input for the file name includes the proper extension.
What does the 'contentBytes' expression do in Power Automate?
The 'contentBytes' parameter specifically extracts the raw binary data of the file rather than a standard base64 encoded string. Passing the raw binary data is necessary to generate a valid, readable PDF file in SharePoint.
Can I repair a corrupted PDF that was already uploaded by a failed flow?
Generally, if a PDF is created with missing or altered binary content during a flow upload, the data is permanently lost and the file cannot be repaired. You must correct the Power Automate flow to preserve the raw binary data and run the upload process again using the original source file.




