How to save SharePoint Site Page as PDF and save PDF to document library

Copper Contributor

I would like to know if it is possible to automate the process of saving a SharePoint site page as a pdf and then saving this pdf into a document library. Currently to do this I have to print the page (ctrl+p) and choose the option to save as pdf. Then once saved to my pc I upload the pdf file to the document library. Is it possible to have a webpart or button on the site page, which automatically does this for me using custom code?

4 Replies
No direct way to do that without some coding / Flow. Just as an example (a little bit out of date, but it's a good sample to look at): https://blog.muhimbi.com/2017/10/converting-sharepoint-online-pages.html
Hello @Tiago_Sa, I have a similar requirement. Did you get any solution that could use CSOM for performing conversion?
Muhimbi, would be a 3rd party product. Is there a way to achieve this using CSOM?

@Tiago_Sa 

 

i created a Windows Autohotkey (https://www.autohotkey.com/) script that runs off the sharepoint site pages list opened in chrome browser with send to pdf as the default printer in my chome print settings.

 

The script is

 

Sleep, 10000
Loop, 100 {
Send, {ENTER}
Sleep, 5000
Send, {CTRLDOWN}p{CTRLUP}
Sleep, 2000
Send, {ENTER}
Sleep, 2000
Send, {TAB 3}{ENTER}
Sleep, 2000
Send, {CTRLDOWN}w{CTRLUP}
Sleep, 1000
Send, {DOWN}
}

 

 

Save this as an .ahk file using Notepad. 

 

Open the site contents page in chrome and check send to pdf is set as the print setting:

 

.....sharepoint.com/sites/YOURSITE/SitePages/Forms/RecentChanges.aspx

 

Play the script using autohotkey(not going to explain that, do some googling research), click on an empty spot next to the first item in the list open in the chrome browser (within 10s) and let the script run, it will loop through up to 100 pages. It is sending standard windows commands that can be interpreted with some common sense upon a bit of study.

 

Note you may have to modify the script to match any differences in the order of your chrome browser print settings. Again i'm not going to help on customising this, it's just to give ideas on whats possible.

 

It does work well for an entire site for me.