Jan 26 2021 02:15 PM
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?
Jan 26 2021 10:43 PM
Dec 05 2022 03:32 AM
Dec 05 2022 03:33 AM
Aug 06 2023 11:12 PM
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.