locked
DOCX/PPTX/XLSX files to EMF/WMF using WAS(Word Automation Services) in SharePoint Server? RRS feed

  • Question

  • Is there any way I can get EMFs out of DOCX/PPTX/XLSX files using word automation services in SharePoint Server ? I don't see this as an option however Can WAS be extended to save documents as EMF/WMFs as well?Kindly help.
    Monday, October 11, 2010 11:38 AM

Answers

  • Hi Vinay,

    In simplest terms, Word Automation Services takes the "Save As…" functionality of the Word client application and replicates it for the server. Specifically, Word Automation Services provides the following capabilities:

    • Opens documents that Word can open, including:

      • Open XML File Format documents (.docx, .docm, .dotx, .dotm).

      • Word 97-2003 documents (.doc, .dot).

      • Rich Text Format files (.rtf).

      • Single File Web Pages (.mht, .mhtml).

      • Word 2003 XML Documents (.xml).

      • Word XML Document (.xml).

    • Supports all automatic tasks that execute when a document opens, such as:

      • Updating the Table of Contents, the Table of Authorities, and index fields.

      • Recalculating all field types.

      • XML mapping.

      • Merging of alternate format chunks.

      • Setting the compatibility mode of the document to the latest version or to previous versions of Word.

    • Saves documents types that Word can save. This list is identical to the previous list of files that the Word Automation Services can open, but also includes the following types:

      • Portable Document Format (PDF) files.

      • XML Paper Specification (XPS) files

    Thanks
    Ankush
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Ankush Microsoft Online Community Support
    • Proposed as answer by Ankush_Bhatia Wednesday, October 13, 2010 10:55 AM
    • Marked as answer by Bessie Zhao Tuesday, November 9, 2010 9:06 AM
    Wednesday, October 13, 2010 10:55 AM
  • Hi Vinay,

    I'm reading 2 distinct questions here.

    1. Can EMF/WMF files be extracted from an Office file saved in the Open XML format?

    2. Is it possible to save a docx file as an EMF picture?

    The answer to question #2 is as Ankush stated above. There is no option builtin to WAS that would allow this conversion.

    Regarding question #1 it may be possible to use the Open XML SDK to develop a solution that would extract these images from the file package and then save them.  Is this what you are trying to do?

    If this is what you are attempting, then this snippet illustrates how to extract a wmf file and save it.

     

    using (WordprocessingDocument doc = WordprocessingDocument.Open(target, true))

    {

     

     

    MainDocumentPart mainPart = doc.MainDocumentPart;

     

    foreach (ImagePart ip in doc.MainDocumentPart.ImageParts)

    {

     

    Stream st = ip.GetStream();

     

    Image ig = Image.FromStream(st);

    ig.Save(

    "c:\\test\\image1.wmf", System.Drawing.Imaging.ImageFormat.Wmf);

     

     

     

     

    }

    }

     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Harold Kless Microsoft Online Community Support
    Monday, October 25, 2010 11:05 PM

All replies

  • Hi Vinay,

    In simplest terms, Word Automation Services takes the "Save As…" functionality of the Word client application and replicates it for the server. Specifically, Word Automation Services provides the following capabilities:

    • Opens documents that Word can open, including:

      • Open XML File Format documents (.docx, .docm, .dotx, .dotm).

      • Word 97-2003 documents (.doc, .dot).

      • Rich Text Format files (.rtf).

      • Single File Web Pages (.mht, .mhtml).

      • Word 2003 XML Documents (.xml).

      • Word XML Document (.xml).

    • Supports all automatic tasks that execute when a document opens, such as:

      • Updating the Table of Contents, the Table of Authorities, and index fields.

      • Recalculating all field types.

      • XML mapping.

      • Merging of alternate format chunks.

      • Setting the compatibility mode of the document to the latest version or to previous versions of Word.

    • Saves documents types that Word can save. This list is identical to the previous list of files that the Word Automation Services can open, but also includes the following types:

      • Portable Document Format (PDF) files.

      • XML Paper Specification (XPS) files

    Thanks
    Ankush
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Ankush Microsoft Online Community Support
    • Proposed as answer by Ankush_Bhatia Wednesday, October 13, 2010 10:55 AM
    • Marked as answer by Bessie Zhao Tuesday, November 9, 2010 9:06 AM
    Wednesday, October 13, 2010 10:55 AM
  • Hi Vinay,

    I'm reading 2 distinct questions here.

    1. Can EMF/WMF files be extracted from an Office file saved in the Open XML format?

    2. Is it possible to save a docx file as an EMF picture?

    The answer to question #2 is as Ankush stated above. There is no option builtin to WAS that would allow this conversion.

    Regarding question #1 it may be possible to use the Open XML SDK to develop a solution that would extract these images from the file package and then save them.  Is this what you are trying to do?

    If this is what you are attempting, then this snippet illustrates how to extract a wmf file and save it.

     

    using (WordprocessingDocument doc = WordprocessingDocument.Open(target, true))

    {

     

     

    MainDocumentPart mainPart = doc.MainDocumentPart;

     

    foreach (ImagePart ip in doc.MainDocumentPart.ImageParts)

    {

     

    Stream st = ip.GetStream();

     

    Image ig = Image.FromStream(st);

    ig.Save(

    "c:\\test\\image1.wmf", System.Drawing.Imaging.ImageFormat.Wmf);

     

     

     

     

    }

    }

     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Regards, Harold Kless Microsoft Online Community Support
    Monday, October 25, 2010 11:05 PM