0

I have to to convert Word file to PDF using WAS with Csom but on Microsoft.Office.Word.Server.Conversions.syncConverter method give exception of Could not load file or assembly 'Microsoft.Office.Server. while Assembly is Added and file is fine. Below is my Code

using (System.IO.StreamReader sr = new System.IO.StreamReader(FileInfo.Stream))
{
    using (MemoryStream pdfContents = new MemoryStream())
    {
        //var proxy = clientContext.Web.Context.ApplicationName..Proxies.Where(p => p is WordServiceApplicationProxy).FirstOrDefault();
        //if (proxy == null)
        //  return null;
        // Initialise Word Automation Service
        SyncConverter sc = new SyncConverter("Word Automation Service Application");
        //sc.UserToken = ;
        sc.Settings.UpdateFields = true;
        sc.Settings.OutputFormat = SaveFormat.PDF;
        // Convert to PDF
        ConversionItemInfo info = sc.Convert(sr.ToString(), pdfContents.ToString());
        if (info.Succeeded)
        {
            var fileStream = new FileStream((string)sourceFile.ServerRelativeUrl, FileMode.Create, FileAccess.ReadWrite);
            pdfContents.WriteTo(fileStream);
        }
        else
        {
        }
    }
}

1 Answer 1

2

WAS cannot be used with CSOM. The class you're referencing is the Server Side Object Model (SSOM). This means that you need to deploy a Full Trust Solution using SSOM.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.