2012-02-18 35 views
5

मैं एचटीएमएल कोड के रूप में पहले पृष्ठ पर शीर्षलेख के साथ "वर्ड डॉक्यूमेंट" उत्पन्न कर रहा हूं। <style> टैग है:कार्यालय एचटीएमएल वर्ड हेडर

@page Section { 
    size:8.5in 11.0in; 
    margin: 0.7in 0.9in 0.7in 0.9in; 
    mso-header-margin: 0.0in; 
    mso-footer-margin: 0.0in; 
    mso-title-page: yes; 
    mso-first-header: fh1; 
    mso-paper-source: 0; 
} 
div.Section { 
    page: Section; 
} 

और <body>:

<div class="Section" style="font-family: Verdana, sans-serif;"> 
    <![if supportFields]> 
     <div style="mso-element:header" id="fh1"> 
      <p class="MsoHeader"> 
       header 
      </p> 
     </div> 
    <![endif]> 
</div> 

यह दोनों शीर्षक में और दस्तावेज़ के मुख्य शरीर में "शीर्षक" पाठ को दर्शाता है। संसाधन (http://techsynapse.blogspot.com/2007/03/generating-word-document-dynamically.html और http://www.pbdr.com/ostips/wordfoot.htm) मैंने पाया है कि अतिरिक्त हेडर फ़ाइल का उपयोग किए बिना इस प्रभाव से बचने का कोई तरीका नहीं है मेरे लिए एक विकल्प नहीं है।

और मेरा प्रश्न है: क्या आप उस समस्या के लिए किसी भी काम को जानते हैं? मैं मुख्य दस्तावेज़ में शीर्षलेख के अवसर को कैसे छुपा सकता हूं लेकिन इसे पृष्ठ के शीर्ष पर अपनी जगह पर छोड़ सकता हूं? सलाह के किसी भी टुकड़े के लिए अग्रिम धन्यवाद।

उत्तर

7

यह मेरे लिए काम किया:

<html 
xmlns:o='urn:schemas-microsoft-com:office:office' 
xmlns:w='urn:schemas-microsoft-com:office:word' 
xmlns='http://www.w3.org/TR/REC-html40'> 
<head><title></title> 

<!--[if gte mso 9]><xml> 
<w:WordDocument> 
    <w:View>Print</w:View> 
    <w:Zoom>90</w:Zoom> 
</w:WordDocument> 
</xml><![endif]--> 


<style> 
p.MsoFooter, li.MsoFooter, div.MsoFooter 
{ 
    margin:0in; 
    margin-bottom:.0001pt; 
    mso-pagination:widow-orphan; 
    tab-stops:center 3.0in right 6.0in; 
    font-size:12.0pt; 
} 
<style> 

<!-- /* Style Definitions */ 

@page Section1 
{ 
    size:8.5in 11.0in; 
    margin:1.0in 1.0in 1.0in 1.0in; 
    mso-header-margin:.5in; 
    mso-footer-margin:.5in; 
    mso-title-page:yes; 
    mso-header: h1; 
    mso-footer: f1; 
    mso-first-header: fh1; 
    mso-first-footer: ff1; 
    mso-paper-source:0; 
} 


div.Section1 
{ 
    page:Section1; 
} 

table#hrdftrtbl 
{ 
    margin:0in 0in 0in 900in; 
    width:1px; 
    height:1px; 
    overflow:hidden; 
} 
--> 
</style></head> 

<body lang=EN-US style='tab-interval:.5in'> 
<div class=Section1> 

<p> CONTENT </p> 

<br/> 
    <table id='hrdftrtbl' border='0' cellspacing='0' cellpadding='0'> 
    <tr><td> 

    <div style='mso-element:header' id=h1 > 
     <p class=MsoHeader ><p>&nbsp;HEADER-TITLE</p></p> 
    </div> 

    </td> 
    <td> 
    <div style='mso-element:footer' id=f1> 

     <p>&nbsp;FOOTER-TITLE</p> 
     <p class=MsoFooter> 
     <span style=mso-tab-count:2'></span> 
      Page <span style='mso-field-code: PAGE '><span style='mso-no-proof:yes'></span></span> of <span style='mso-field-code: NUMPAGES '></span> 
     </p> 

    </div> 



    <div style='mso-element:header' id=fh1> 

    <p class=MsoHeader><span lang=EN-US style='mso-ansi-language:EN-US'>&nbsp;FIRST-HEADER-TITLE<o:p></o:p></span></p> 

    </div> 

    <div style='mso-element:footer' id=ff1> 

    <p class=MsoFooter><span lang=EN-US style='mso-ansi-language:EN-US'>&nbsp;FIRST-FOOTER-TITLE<o:p></o:p></span></p> 

    </div> 

    </td></tr> 
    </table> 


</body></html> 
+0

यह हमेशा मेरे लिए एक अतिरिक्त जगह प्रदर्शित करता है। – Ryan

+1

सर्वर से शीर्षलेख में छवि उत्पन्न करने में सक्षम नहीं है लेकिन स्थानीयहोस्ट पर यह ठीक काम कर रहा है। छवि के लिए जेनरेट किया जा रहा पथ भी सर्वर पर ठीक है। क्या आप कृपया मुझे बताएं कि मुझे क्या याद आ रहा है कि स्थानीयहोस्ट छवि पर शब्द फ़ाइल में जोड़ा जा रहा है लेकिन सर्वर पर नहीं। ** नोट ** स्थानीय मशीन पर मेरे पास एमएस-ऑफिस स्थापित है लेकिन सर्वर पर नहीं। –

+0

शीर्षलेख अनुभाग पर खाली स्थान को कैसे निकालें? जब मैं इसे शब्द में देखता हूं सबकुछ ठीक है लेकिन जब मुद्रित किया जाता है तो रिक्त स्थान जोड़ा जाता है ... कोई विचार? –

3

Vencedor से ऊपर जवाब पर अद्यतन करें और हटाने के अतिरिक्त खाली वर्ण एन्कोडिंग अपने शीर्षलेख/पादलेख छवियों/पाठ को जोड़ा गया आप कुछ इस तरह कर सकते हैं करने के लिए:

<html 
xmlns:o='urn:schemas-microsoft-com:office:office' 
xmlns:w='urn:schemas-microsoft-com:office:word' 
xmlns='http://www.w3.org/TR/REC-html40'> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<title></title> 

<!--[if gte mso 9]><xml> 
<w:WordDocument> 
    <w:View>Print</w:View> 
    <w:Zoom>100</w:Zoom> 
</w:WordDocument> 
</xml><![endif]--> 
<style> 
<!-- /* Style Definitions */ 
p.MsoHeader, li.MsoHeader, div.MsoHeader{ 
    margin:0in; 
    margin-top:.0001pt; 
    mso-pagination:widow-orphan; 
    tab-stops:center 3.0in right 6.0in; 
} 
p.MsoFooter, li.MsoFooter, div.MsoFooter{ 
    margin:0in 0in 1in 0in; 
    margin-bottom:.0001pt; 
    mso-pagination:widow-orphan; 
    tab-stops:center 3.0in right 6.0in; 
} 
.footer { 
    font-size: 9pt; 
} 
@page Section1{ 
    size:8.5in 11.0in; 
    margin:0.5in 0.5in 0.5in 0.5in; 
    mso-header-margin:0.5in; 
    mso-header:h1; 
    mso-footer:f1; 
    mso-footer-margin:0.5in; 
    mso-paper-source:0; 
} 
div.Section1{ 
    page:Section1; 
} 
table#hrdftrtbl{ 
    margin:0in 0in 0in 9in; 
} 
--> 
</style> 
<style type="text/css" media="screen,print"> 
body { 
    font-family: "Calibri", "Verdana","HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif; 
    font-size:12pt; 
} 
pageBreak { 
    clear:all; 
    page-break-before:always; 
    mso-special-character:line-break; 
} 
</style> 
</head> 
<body style='tab-interval:.5in'> 
<div class="Section1"> 

Something page 1 
<div class="pageBreak"></div> 
Something page 2 
<div class="pageBreak"></div> 

<table id='hrdftrtbl' border='1' cellspacing='0' cellpadding='0'> 
     <tr> 
      <td> 
       <div style='mso-element:header' id="h1" > 
        <p class="MsoHeader"> 
         <table border="0" width="100%"> 
          <tr> 
           <td> 

            YOUR_HEADER IMAGE/TEXT 

           </td> 
          </tr> 
         </table> 
        </p> 
       </div> 
      </td> 
      <td> 
      <div style='mso-element:footer' id="f1"> 
       <p class="MsoFooter"> 
        <table width="100%" border="0" cellspacing="0" cellpadding="0"> 
         <tr> 
          <td align="center" class="footer"> 
          YOUR_FOOTER_TEXT 
           <g:message code="offer.letter.page.label"/> <span style='mso-field-code: PAGE '></span> of <span style='mso-field-code: NUMPAGES '></span> 
          </td> 
         </tr> 
        </table> 
       </p> 
      </div> 
     </td> 
    </tr> 
    </table> 
    </div> 
</body> 
</html> 

इसमें अब हेडर और फ़ूटर सेगमेंट के लिए पूर्ण सीएसएस घटक शामिल हैं।

चाल जो वास्तव में अतिरिक्त एन्कोडिंग को हटाती है वह मसूफूटर और एमएसएचडर अनुभागों के भीतर एक और तालिका घोषित कर रही है।

+0

बहुत उपयोगी, धन्यवाद! क्या आप जानते हैं कि कोई ऐसी संपत्ति है जो बॉडी टेक्स्ट को हेडर सेक्शन पर ओवरलैप करने की अनुमति दे सकती है? जैसा कि अब यह है कि बॉडी टेक्स्ट हमेशा हेडर की आखिरी पंक्ति से नीचे जाता है। –

+1

यहां एक नज़र डालें http://sebsauvage.net/wiki/doku.php?id=word_document_generation। हमने mhtml मॉडल (बहुत नीचे) का उपयोग कर समाप्त कर दिया है और यह पूरी तरह से काम करता है। इस वर्तमान विधि के साथ समस्या छिपी हुई तालिका है कि हमारे मामले में एक अतिरिक्त पृष्ठ बना रहा था जब अंतिम पृष्ठ आधे रास्ते से अधिक था। – Vahid

+0

हां यह बिल्कुल ट्यूटोरियल है जिसे मैंने सफलतापूर्वक उपयोग किया है। लेकिन मैं हेडर को टेक्स्ट ओवरलैप करने का प्रबंधन नहीं करता हूं। एक अन्य विकल्प हेडर के बजाय वॉटरमार्क का उपयोग करना होगा, लेकिन यह हेडर एचटीएमएल को एक तस्वीर में परिवर्तित करने का संकेत देगा और यह आसान नहीं होगा:/ तो यदि आपके पास पृष्ठ के शीर्ष पर बॉडी टेक्स्ट शुरू करने की चाल है, तो यहां तक ​​कि यदि कोई हेडर है, तो यह बहुत अच्छा होगा :) –

संबंधित मुद्दे