Have you thought about saving your Word documents as XML? IIRC you need Office Professional version to do this.

This would allow you to display the document over the web with out changing it (IE will figure out and display the file properly using XSL). As well you can lock the file down by using web server controls. This would result in users being able to modify the client side doc but not being able to save it back to the server unless they do it your way.

When a user downloads then saves a document back the server you can then check that the file contains the proper header (both text and images can be supported), if it does not then you can delete the old header and put a new one in it's place. Update

The body of the Word doc is contained within the <w:body> tags. This also contains the header and footer information in it as well. The header/footer info is stored under the <w:sectPr> node.

Here is a bare body that only contains the word "BODY".

<w:body> <wx:sect> <w:p> <w:r> <w:t>BODY</w:t> </w:r> </w:p> <w:p/> <w:p/> <w:p/> </wx:sect> </w:body>
Here is document body with the header and footer.
<w:body> <wx:sect> <w:p> <w:r> <w:t>BODY</w:t> </w:r> </w:p> <w:p/> <w:p/> <w:p/> <w:sectPr> <w:hdr w:type="odd"> <w:p> <w:pPr> <w:pStyle w:val="Header"/> </w:pPr> <w:r> <w:t>Header1</w:t> </w:r> <w:r> <w:tab wx:wTab="3525" wx:tlc="none" wx:cTlc="58"/> </w:r> <w:r> <w:tab wx:wTab="4320" wx:tlc="none" wx:cTlc="71"/> </w:r> </w:p> </w:hdr> <w:ftr w:type="odd"> <w:p> <w:pPr> <w:pStyle w:val="Footer"/> </w:pPr> <w:r> <w:t>Footer1</w:t> </w:r> </w:p> </w:ftr> <w:pgSz w:w="12240" w:h="15840"/> <w:pgMar w:top="1440" w:right="1800" w:bottom="1440" w:left="1800" w:h +eader="720" w:footer="720" w:gutter="0"/> <w:cols w:space="720"/> <w:docGrid w:line-pitch="360"/> </w:sectPr> </wx:sect> </w:body>
Hope this helps.

In reply to Re: Manipulating MSWord files in a linux box? by terra incognita
in thread Manipulating MSWord files in a linux box? by DaWolf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.