We now know about the fantastic feature called word automation service. Now it’s not just that you can do it with the help of code.
If you are a server administrator, then again PowerShell is here to help you out with this. PowerShell is undoubtedly one of the best enhancements that have come with SharePoint 2010 which gives more power than traditional stsadm command for sure.
So open up the Start menu - >Administrative Toos -> Windows PowerShell Module.
We are using the same library that we have used in Part 1.
Now start writing following commands one after the other and see the magic. Again remember you need to wait for some time depends on the source file format and destination file format to get the output.
PowerShell also provides you way to check the status of the process the same way we checked with the code in part 1.
First we need to take the proxy reference of the word automation service. But yes, make sure that word automation service should be running.


Now we will take the reference of the site

Now we need to set the input and output folder. It means source library path and destination library path. I am going to have it both at the same place.

Now we will take the reference of conversion job we created in first step, set up the user token under which the job will run, output format and should we override the file if already there or not.

Now then once we configure all these, it’s time to start the job to convert.
So your overall code would look something like this

At the same time, we can query the conversion status as well.

As you can see it shows the status, you can keep checking the status. After process started, it will be number of documents in progress and at the end if you query, it will be number of documents completed.
Default time is 15 minutes. You need to wait till 15 minutes, but if you do not want to wait till 15 minute then you can force job to run.

and Here is the output. If you have multiple files, it will automatically take all files and convert them to PDF.

2 comments:
we can even reset the 15min schedule to 1 min by using power shell command
Get-SPTimerJob | Where-Object {$_.Displayname -eq "Word Automation Services Timer Job"}
$NewSchedule = new-object Microsoft.SharePoint.SPMinuteSchedule
$NewSchedule.Interval = 1
$job.Schedule = $NewSchedule
$job.Update()
The timer job can be set to 1 min schedule by using the powershell command below :
Get-SPTimerJob | Where-Object {$_.Displayname -eq "Word Automation Services Timer Job"}
$NewSchedule = new-object Microsoft.SharePoint.SPMinuteSchedule
$NewSchedule.Interval = 1
$job.Schedule = $NewSchedule
$job.Update()
Post a Comment