• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Dynamically generated Word doc has double headers and footers

Explorer ,
Jul 25, 2016 Jul 25, 2016

Copy link to clipboard

Copied

Hi,

I'm able to use CFcontent and CFheader tags etc. to generate a Word doc with dynamic data on the fly and such Word doc has several pages.  An issue is the last page has double headers and footers.  The following is the process:

1) <cfsavecontent 
    variable = "WDcontent">

2) Use Microsoft XML and Word style guide

<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>

<style>

  1. p.MsoHeader, li.MsoHeader, div.MsoHeader
        {margin:0in;
        margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        tab-stops:center 3.0in right 6.0in;}

    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:10.0pt;}
                                   
    @page Section1
        {size:8.5in 11.0in;
         margin:1.0in 1.25in 1.0in 1.25in ;
         mso-header: h1;
         mso-footer: f1;
         mso-header-margin:.5in;
         mso-footer-margin:.5in; mso-paper-source:0;}
    div.Section1 
        {page:Section1;}

    // header & footer area
    table#hrdftrtbl
    {
        margin:0in 0in 0in 9in;
    }    

</style>

3) continue with HTML body output

toward the end and before the top level DIV ends,

add the header and footer reference,

    <table id='hrdftrtbl' border='0' cellspacing='0' cellpadding='0'>
        <tr>
            <td>
                <div style='mso-element: header' id="h1">
                    <p style='text-align: center'>
                    <img src="#baseURL#/header2.png" width="90%" height="75">
                    </p>
                </div>
            </td>
   
            <td>   
                <div style='mso-element: footer' id="f1">
                    <p align="right">
                        <span style=mso-tab-count:2'>
                        <img src="#baseURL#/footer2.png" width="90%" height="15">
                        </span>
                        </p>
                </div>
            </td>
        </tr>       
    </table>

Then, after HTML closing


</cfsavecontent>

4) direct output to Word

<!--- WORD version --->
<cfheader name="content-disposition" value="filename=myNew.doc">
<cfcontent type="application/msword">

<cfprocessingdirective suppressWhiteSpace = "true">
<cfoutput>#WDcontent#</cfoutput>
</cfprocessingdirective>

Thoughts?

tia.

Views

2.6K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jul 26, 2016 Jul 26, 2016

Solved.

Votes

Translate

Translate
Explorer ,
Jul 26, 2016 Jul 26, 2016

Copy link to clipboard

Copied

Solved.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 26, 2016 Jul 26, 2016

Copy link to clipboard

Copied

Please share.  I'm curious, myself.  And maybe someone else runs across the same issue, and could use your wisdom on this.

V/r,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 28, 2016 Jul 28, 2016

Copy link to clipboard

Copied

pm me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 01, 2016 Aug 01, 2016

Copy link to clipboard

Copied

Unless your code is proprietary, it would be better to post your solution here (as WolfShade​ suggested) for the future benefit of anyone who encounters the same issue.  If you aren't willing to do that, then maybe you can delete the question entirely so it doesn't become a "dead end" of frustration for those who come along later.


Thank you,

-Carl V. - Moderator

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 17, 2020 Nov 17, 2020

Copy link to clipboard

Copied

LATEST

Well, i guess i'm f*cked 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation