SharePoint 2013: Replace the PDF icon
I uploaded a PDF to SharePoint 2013 and noticed that the PDD icon is not the official and recognizable Adobe PDF icon. In this article I will tell you how to replace the SharePoint 2013 PDF icon.
Is it a document with a belt or what ? Nevermind I don’t like it and I am very certain that most of the users out there do not recognize the icon – and that is the main purpose of the icon right?
With SharePoint 2010 there was no PDF support out of the box – afaik there was no icon at all. I should be happy and quite right? Nope, created a small powershell that replaced the icon (either you place it next to the script or the script downloads it from the Adobe page).
The result will look like this – way better if you ask me.
Powershell to the rescue – once again!
And here comes the small script:
- #########################################################################################
- # by Max Melcher, http://melcher.it, @maxmelcher
- # Feel free to change and reuse as you wish - use on your own risk
- # Script that replaces the OOTB SharePoint 2013 PDF icon with the orignal Adobe PDF icon.
- # Execute on each webfrontend
- #########################################################################################
- #settings
- $destination = "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\IMAGES\icpdf.png"
- #Check if the icon exists otherwise download it
- $item = Get-ChildItem pdficon_small.png -ErrorAction SilentlyContinue
- #Helper
- function download{
- # usage: download http://url c:\temp
- param([string]$URL, [string]$destination)
- Write-Host "Downloading $URL ..."
- $clnt = new-object System.Net.WebClient -ErrorVariable err -ErrorAction "SilentlyContinue"
- $clnt.DownloadFile($url,$destination)
- if ([String]::IsNullOrEmpty($err) -eq $true)
- {
- Write-Output " - Download completed."
- }
- else
- {
- Write-Error "Download ERROR - Check URL: $err"
- }
- }
- function RestartIIS(){
- $title = "Restart IIS"
- $message = "Do you want to restart the local IIS?"
- $yes = New-Object System.Management.Automation.Host.ChoiceDescription "Yes","Restarts IIS."
- $no = New-Object System.Management.Automation.Host.ChoiceDescription "No","Silently continues..."
- $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
- $result = $host.ui.PromptForChoice($title, $message, $options, 0)
- if ($result -eq 0){
- Write-Host -ForegroundColor Yellow "Restarting IIS"
- iisreset /noforce
- }
- }
- if ($item)
- {
- Write-Host -ForegroundColor Yellow "Supplied icon found - overwriting"
- Copy-Item $item -Destination $destination -Force
- }
- else
- {
- Write-Host -ForegroundColor Yellow "Downloading icon from Adobe"
- Download "http://www.adobe.com/images/pdficon_small.png" $destination
- }
- Write-Host -ForegroundColor Green "Icon replaced"
- #Icon will only be changed after iisreset or reboot
- RestartIIS
- Write-Host -ForegroundColor Green "done!"
No comments:
Post a Comment