Exception when trying to run Word Automation Services in SharePoint 2013

2.7k views Asked by At

I try to convert a docx-file to pdf by using the following simple Code:

ConversionJobSettings jobSettings = new ConversionJobSettings();
jobSettings.OutputFormat = SaveFormat.PDF;
ConversionJob job = new ConversionJob("Word Automation Services", jobSettings);
job.AddFile(path + docFilename, path + pdfFilename);
job.Start();

But when I try to run the code I get an exception:

A Word Automation Services application proxy with name 'Word Automation Services' cannot be found

In the service applications, both

Word Automation Services

and

Word Automation Services Proxy

are started.

I use Microsoft.Word.Office.Server (from C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\ISAPI)

(UPDATE:) It does seem to work when I add my own proxy and use that name, but that should not be necessary, right?

3

There are 3 answers

0
Ole Albers On BEST ANSWER

I used the following snippet:

 WordServiceApplicationProxy proxy =
                            (WordServiceApplicationProxy)
                                SPServiceContext.GetContext(SPContext.Current.Web.Site)
                                    .GetDefaultProxy(typeof (WordServiceApplicationProxy));

                        ConversionJob job = new ConversionJob(proxy); //, jobSettings);

Seems like my proxy is not called "Word Automation Services", but "Word Automation Services Application"

Like that approach even more, no "magic strings"

0
D__ On

Central Administration -> Application Management -> Configure service application associations ->

check if the Application Proxy Group asociated to your web application has the "Word Automation Service", if not add him to Application Proxies

enter image description here

1
dariom On

I think you need to use the proxy name "Word Automation Services Proxy" in the ConversionJob constructor:

ConversionJobSettings jobSettings = new ConversionJobSettings();
jobSettings.OutputFormat = SaveFormat.PDF;
ConversionJob job = new ConversionJob("Word Automation Services Proxy", jobSettings);
job.AddFile(path + docFilename, path + pdfFilename);
job.Start();