Converting SharePoint site pages into PDFs can be useful for creating reports, archives, or offline documentation. In this step-by-step guide, we’ll walk through how to automate this process using Power Automate.
Step 1: Create a Power Automate Flow
Start by creating a new Power Automate flow.
You can trigger it manually or configure it to run on a schedule or in response to a specific event, depending on your requirements.
Step 2: Initialise Department Variable
Add an Initialise Variable action to store the department name.
This variable will be used later when creating folders inside your document library.
Step 3: Initialise PDF File Name Variable
Next, create another Initialise Variable to hold the PDF file name that will be generated for each site page.
Step 4: Get Site Pages
Add a Get Files (Properties Only) action and point it to your Site Pages library.
You can apply a Filter Query to limit the results, or leave it blank to fetch all site pages.
Step 5: Apply to Each Site Page
Insert an Apply to Each loop and select the value output from the previous “Get Files” action.
Step 6: Set Department Variable
Inside the loop, set the Department variable using the value from your DepartOwner (or equivalent) column from the “Get Files” action.
💡 Replace the column name if your field name differs.
Step 7: Set PDF File Name Variable
Now, set the PDF file name dynamically using the page title:
concat(items('Apply_to_each')?['Title'], '.pdf')
Step 8: Get Canvas Content from Site Page
Add a Send an HTTP Request to SharePoint action.
Use it to retrieve the canvas content of each site page.
Pass the ID of the page from the “Get Files” action to get its content.
Step 9: Parse Canvas Content
Add a Parse JSON action to interpret the response from the previous HTTP request.
Use the Body output from the “Send an HTTP Request to SharePoint” step.
Step 10: Create a Temporary HTML File in OneDrive
Next, add a Create File action (in OneDrive).
This will temporarily store the HTML version of the site page.
File Name: concat(items('Apply_to_each')?['Title'], '.html')
Step 11: Convert HTML to PDF
Use the Convert File action (OneDrive) to convert the HTML file into a PDF.
Pass the File ID from the previous “Create File” step.
Step 12: Create a Folder in SharePoint
Add a Create New Folder action in your SharePoint Document Library.
Set the Folder Path using your Department variable to organise PDFs by department.
Step 13: Upload the PDF to SharePoint
Add a Create File (SharePoint) action.
This will create the final PDF inside the folder created in the previous step.
Step 14: Delete Temporary HTML File
Finally, clean up the temporary HTML file created in OneDrive.
Add a Delete File (OneDrive) action and pass the File ID from the earlier “Create File” step.
Once your flow is complete, run it manually (or trigger it automatically as configured). Your SharePoint site pages will now be converted into well-organised PDF files stored neatly in your document library.
If you have any questions you can reach out our SharePoint Consulting team here.














No comments:
Post a Comment