none
Save xml word file as pdf with office2007 programmatically RRS feed

  • Question

  • Hi,

    I need to save word xml file as pdf using office2007 utilities and vsto without opening the word application.

    How can i did do this ?
    Thnx,
    Wednesday, December 16, 2009 7:38 AM

Answers

  • You can't do that with any MS libraries with Office 2007. That being said, in Office 2010 you can take advantage of a brand new service called Word Automation Services. This service will allow you to convert Word documents as PDF without automating Office client.
    Zeyad Rajabi (MS)
    • Marked as answer by khalil salhi Monday, January 18, 2010 5:01 AM
    Thursday, December 17, 2009 8:34 PM
  • Hi,

    I understand from the link above that i can save XML word file as PDF without requireing to open word application.
    But i have another questions :

    1.For the following code which references should i add, to my cs code ?
    public void Convert_Click(…)
    {
        ConversionJob job = new ConversionJob("Word Automation Services")
        job.UserToken = SPContext.Site.UserToken;
        job.UpdateFields = true;
        job.OutputFormat = SaveFormat.XPS;
        job.AddFile("http://contoso.com/input/foo.docx","http://contoso.com/output/foo.xps");
        job.Start();
    }

    2. The job.Start() method is it async ? If i should call checkstatus after the Start() method run inorder to see if the process success or not.

    public void CheckStatus(Guid jobId)
    {
        ConversionJobStatus status = new ConversionJobStatus("Word Automation Services", jobId, null);
        if (status.Count == status.Succeeded)
        {
            //success!
            //do something
        }
        else if (status.Count == status.Failed)
        {
            //failure :(
            //do something else
        }
        …
    }

    3. Inorder to run it on the server side, is it enough to install office2007 ?

    Thnx,

    • Marked as answer by khalil salhi Monday, January 18, 2010 5:01 AM
    Sunday, December 20, 2009 6:40 AM

All replies

  • You can't do that with any MS libraries with Office 2007. That being said, in Office 2010 you can take advantage of a brand new service called Word Automation Services. This service will allow you to convert Word documents as PDF without automating Office client.
    Zeyad Rajabi (MS)
    • Marked as answer by khalil salhi Monday, January 18, 2010 5:01 AM
    Thursday, December 17, 2009 8:34 PM
  • Hi,

    I understand from the link above that i can save XML word file as PDF without requireing to open word application.
    But i have another questions :

    1.For the following code which references should i add, to my cs code ?
    public void Convert_Click(…)
    {
        ConversionJob job = new ConversionJob("Word Automation Services")
        job.UserToken = SPContext.Site.UserToken;
        job.UpdateFields = true;
        job.OutputFormat = SaveFormat.XPS;
        job.AddFile("http://contoso.com/input/foo.docx","http://contoso.com/output/foo.xps");
        job.Start();
    }

    2. The job.Start() method is it async ? If i should call checkstatus after the Start() method run inorder to see if the process success or not.

    public void CheckStatus(Guid jobId)
    {
        ConversionJobStatus status = new ConversionJobStatus("Word Automation Services", jobId, null);
        if (status.Count == status.Succeeded)
        {
            //success!
            //do something
        }
        else if (status.Count == status.Failed)
        {
            //failure :(
            //do something else
        }
        …
    }

    3. Inorder to run it on the server side, is it enough to install office2007 ?

    Thnx,

    • Marked as answer by khalil salhi Monday, January 18, 2010 5:01 AM
    Sunday, December 20, 2009 6:40 AM