Click here to Skip to main content
15,793,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i follwed this Article:
<a href=""></a>

What I have tried:

using System;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Workflow;
using Microsoft.Office.Word.Server.Conversions;

namespace WordTopdf.ConversionLibrary.PDF_EventReceiver1
    /// <summary>
    /// List Item Events
    /// </summary>
    public class PDF_EventReceiver1 : SPItemEventReceiver
        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
              // Verify the document added is a Word document
      // before starting the conversion.
      if (properties.ListItem.Name.Contains(".docx"))
        //Variables used by the sample code.
        ConversionJobSettings jobSettings;
        ConversionJob pdfConversion;
        string wordFile;
        string pdfFile;
        string wordAutomation = "WAS";

        // Initialize the conversion settings.
        jobSettings = new ConversionJobSettings();
        jobSettings.OutputFormat = SaveFormat.PDF;

        // Create the conversion job using the settings.
        pdfConversion =
          new ConversionJob(wordAutomation, jobSettings);//[i am getting an error in here]

        // Set the credentials to use when running the conversion job.
        pdfConversion.UserToken = properties.Web.CurrentUser.UserToken;

        // Set the file names to use for the source Word document
        // and the destination PDF document.
        wordFile = properties.WebUrl + "/" + properties.ListItem.Url;
        if (properties.ListItem.Name.Contains(".docx"))
          pdfFile = wordFile.Replace(".docx", ".pdf");
          pdfFile = wordFile.Replace(".docx", ".pdf");

        // Add the file conversion to the conversion job.
        pdfConversion.AddFile(wordFile, pdfFile);

        // Add the conversion job to the Word Automation Services 
        // conversion job queue. The conversion does not occur
        // immediately but is processed during the next run of
        // the document conversion job.

Richard MacCutchan 6-Nov-16 3:22am    
Did you have a question?
jagdeesh 93 6-Nov-16 4:26am    
my requirement is using WAS(WordAutomationServices) in sharepoint2013 i need to convert .docx files in Folder-A Should automatically converted into .pdf files in Folder-B(i.e.,it should automatically copy and convert the document into pdf format from source folder to destination folder).
can you help me to solve this??
[no name] 6-Nov-16 9:33am    
That is a requirement. It is not a question or a description of the problem.
jagdeesh 93 7-Nov-16 0:21am    
WORD AUTOMATION SERVICES IN SP2013 is not loaded by the conversion job. i check the services all are running. the error while debugging in visual studio is :"proxy file cannot be found"
jagdeesh 93 7-Nov-16 3:52am    
for starting the conversionjob i use :


this error is occuring: "The service application required to complete this request is not currently available. Try this operation again later. If the problem persists, contact your administrator."

-- how to solve this error??

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900