none
Save binary data together with Word document RRS feed

  • Question

  • CustomeXMLParts is used to save XML data into Word document. What's the best way to save binary data in Word document? There's no need for user to view the binary data, it's for our application to use, just want to pack the data into Word document.
    Thursday, February 6, 2014 2:12 PM

Answers

  • Hi James

    Same way, in a Custom XML Part, just put it into an XML element (CDATA type, perhaps, if the binary data contains odd characters) so that the XML is well-formed. You can extract it from the element in order to use it.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, February 6, 2014 4:41 PM
    Moderator

All replies

  • Hi James

    Same way, in a Custom XML Part, just put it into an XML element (CDATA type, perhaps, if the binary data contains odd characters) so that the XML is well-formed. You can extract it from the element in order to use it.


    Cindy Meister, VSTO/Word MVP, my blog

    Thursday, February 6, 2014 4:41 PM
    Moderator
  • Hi Cindy,

    Thank you for the solution. Could you please post sample code to put byte array into CDATA? I could not find a way to save byte array into CDATA without using Base64Encoding. I would like to avoid the overhead of encoding/decoding.

    James

    Tuesday, February 18, 2014 2:31 PM
  • Hi James

    I'm afraid I don't have experience with doing exactly that. Try asking in a "pure" XML forum?


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, February 19, 2014 3:56 PM
    Moderator
  • Will do. Thanks.

    Wednesday, February 19, 2014 4:36 PM