aadel112 / googoose

A jquery plugin that allows an html page to be converted and/or downloaded into a Microsoft Word Document with an emphasis on performance
Apache License 2.0
38 stars 25 forks source link

Header/Footer Not Working Properly #11

Open hausman-gdit opened 3 years ago

hausman-gdit commented 3 years ago

Was there a mistake in the patch-2 merge?

image

Headers/footers do not work for me when using the main branch that has ...class=headerArea ... class=footerArea...

Also headers and footers do not work for me without thtml.find(options.headerarea)[0].replaceWith(''); & thtml.find(options.footerarea)[0].replaceWith('');

image

Using exampleTest.html from https://github.com/hausman-gdit/googoose I get another header & footer at the end of the document.

image

Any ideas? I'll keep plugging away! Thanks for the neat library.

aadel112 commented 3 years ago

Thanks for the example. I'm looking into this, too.

aadel112 commented 3 years ago

I think the path to success on this is going to be either hiding the content on the document or removing it somehow without affecting the header. Maybe something with style and view guards. I was trying a few things last night. You're welcome for the library. I wrote it a while ago. I'm just glad it's getting noticed nowadays.

aadel112 commented 3 years ago

In fairness to this plugin, that older version with the table used to work in the versions of ms word available at the time. But for me, that does not seem to anymore with the latest version of word. Your branch seems close. Perhaps, a review of the xml schemas referenced will also help.

aadel112 commented 3 years ago

I used to get the html for these elements by generating them in a fresh word document, and then saving as mshtml, I believe, so if you can figure out a way to do that, that would probably also give you what you're looking for. My version of word no longer seems to have that option, but I'll keep trying as well. That's why it was using a table, because ms word was using a table at the time. I notice that when it changed to a div, the css rule table#googoose-headerftrtbl did not change, so there may be something in there that can fix this too. Good luck. I'll keep trying as I have time as well.

hausman-gdit commented 3 years ago

Ahh. Ok! I'll try to see if I can something working via saving the document I'm trying to emulate as .mht / .mhtml. Interestingly in the 'web view' it hides the headers & footers, but they're still there when I switch the view back.

I may be able to sanitize the document enough so that I can share a copy for testing/reference. I may need to wait on authorization to even publish a sanitized version.

I am using Office 365, I will see if I can try it on an older version of Word as well.

aadel112 commented 3 years ago

Please checkout 9dcdcad and modify your html header and footer areas to match googoose.html in the examples. This is working for me in Office 365 and Office 2007, which were my two test versions.

hausman-gdit commented 3 years ago

Thanks for the update! It does work better but I'm also getting a lot of additional whitespace in my test.

image image

I tried your googoose.html as well and had a similar whitespace issue.

image

I should have time today to take a closer look at things. I'm guessing you didn't have a similar issue?

aadel112 commented 3 years ago

I'd tried yours later, and noticed I did have that issue. I think the behavior is correct on the main html, though, because it lists a page break after and before.

    <div class='googoose break'></div>
    <h1>Page Breaks</h1>
    <p>
    You can even define and make page breaks
    </p>

    <div class='googoose break'></div>

I was looking into you issue. I think part of what's causing it is the amount of text in the footer.

hausman-gdit commented 3 years ago

I've taken the example.html and trimmed out page breaks

With header & footer commented out this is what I get:

When the header & footer are not commented out I get this:

image

The additional space does seem to relate to the length of the header & footer text image

image

jondo89 commented 3 years ago

I seem to have the same problem with this and managed to fix it by preventing the use of DIV elements in the header. p elements work ok, but img items in div are invisible, and any text in a div make the doc "infinity pages" long. I suspect the div width has something to do with it. The tables are working well now. i,e <div>Text text</div> will not work <p>Text text</p> will work.

MuhammadAsadUllah821 commented 2 years ago

I have looked all over the internet to get any resolution for this but failed. Did anyone find any solution to this issue? I read somewhere that mso-hide can work but it doesn't do anything.

mhdaktar commented 2 years ago

Was there a mistake in the patch-2 merge?

image

Headers/footers do not work for me when using the main branch that has ...class=headerArea ... class=footerArea...

Also headers and footers do not work for me without thtml.find(options.headerarea)[0].replaceWith(''); & thtml.find(options.footerarea)[0].replaceWith('');

image

Using exampleTest.html from https://github.com/hausman-gdit/googoose I get another header & footer at the end of the document.

image

Any ideas? I'll keep plugging away! Thanks for the neat library.

Replace this line

html += ( 'table#' + options.headerfooterid + ' {\n' ); html += '\tmargin:0in 0in 0in 900in;width:1px;height:1px;overflow:hidden;\n';