top of page

How to convert docx to pdf document in SharePoint 2010 using PowerShell

Updated: Mar 29, 2019

In this article we will be seeing how to convert .docx document to pdf document in SharePoint 2010 using powershell.

Word Automation Services is a new feature available in SharePoint 2010. It supports converting Word documents to other formats. Here we are going to convert the word document into pdf document.

This article describes the following steps to show how to call the Word Automation Services to convert a document:

  • Add a word document to the SharePoint Shared Documents.

  • Create ConvertWordToPDF.ps1 file.

Add a word document in the Shared Documents:

Create a ConvertWordToPDF.ps1 file:

# Input parameters for the script

$wordFile="http://servername:4040/Shared%20Documents/ExternalList.docx" $pdfFile="http://servername:4040/Shared%20Documents/ExternalList.pdf"

# Get the Word Automation Service Proxy

$wasp = Get-SPServiceApplicationProxy | where { $_.TypeName -eq "Word Automation Services Proxy" }

#Create the Conversion job

$conversionJob = New-Object Microsoft.Office.Word.Server.Conversions.ConversionJob($wasp)

# Get the web url

$web = Get-SPWeb "http://servername:4040/"

# Set the credentials to use when running the conversion job.

$conversionJob.UserToken = $web.CurrentUser.UserToken

# Conversion Job Name

$conversionJob.Name = "Convert docx to PDF" $conversionJob.Settings.OutputFormat = [Microsoft.Office.Word.Server.Conversions.SaveFormat]::PDF $conversionJob.AddFile($wordFile,$pdfFile)

# Start the conversion job

$conversionJob.Start()

Open the SharePoint 2010 Management Shell as an Administrator. Run the ConvertWordToPDF.ps1 file.

Go to the Shared Documents in SharePoint 2010, pdf file will be created as shown in the following.


0 comments
bottom of page