Ole Albers
Ole Albers

Reputation: 9305

Exception when trying to run Word Automation Services in SharePoint 2013

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?

Upvotes: 0

Views: 2841

Answers (3)

D__
D__

Reputation: 141

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

Upvotes: 0

Ole Albers
Ole Albers

Reputation: 9305

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"

Upvotes: 0

dariom
dariom

Reputation: 4578

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();

Upvotes: 0

Related Questions