none
How to change mainpart name ? RRS feed

  • Question

  • Hello

    I'm using the OpenXML SDK 2.0 in order to generate a new document from a template

    First I copy it :

    System.IO.File.Copy(sourceFile, destFile);

    Then I change the file type :

    WordprocessingDocument wdDoc = WordprocessingDocument.Open(destFile, true);

    wdDoc.ChangeDocumentType(WordprocessingDocumentType.Document);

    Then I do my stuff and save the changes.

     

    The problem occurs when I try to open the new document in a Telerik Silverlight control.

    Here is the answer of the Tk support service :

    "The issue is that the main document is exported as document2.xml in the archive instead of document.xml. I am not familiar with the SDK, but you may be able to work around that issue if you can make it export the more widely accepted document.xml instead of document2.xml."

    So my question is :

    How do I prevent the archive\word\document.xml to be renamed has archive\word\document2.xml while using the WordprocessingDocument.ChangeDocumentType() method ?

    Or, how is it possible, using the SDK, to rename the archive\word\document2.xml back into archive\word\document.xml ?

    Friday, June 17, 2011 9:18 AM

All replies

  • I am not familiar enough with the SDK to give you an answer, but document2.xml (or, indeed, foo.bar) is a valid name and any half-way decent consumer ought to be able to work with it. If they can't, then they are not unpacking the archive correctly and one must wonder what else they are getting wrong.
     

    Enjoy,
    Tony
    www.WordArticles.com
    Friday, June 17, 2011 9:26 AM
  • I am having a similar issue. In particular iWorks Pages does not like the naming change on the documents main part.
    Friday, October 7, 2011 4:08 PM
  • All I can really suggest is complaining to Apple!
     

    Enjoy,
    Tony
    www.WordArticles.com
    Friday, October 7, 2011 4:45 PM