How to remove the header from a Google document once added

Once you add a header to a Google document, it offsets the top of the document even if empty, and receives click events. How can you then remove the header?

I am aware that you can reduce the header’s effects by decreasing the page’s top margin, and reducing the font size in the header—those are not the solutions I am looking for. I would like a way to actually REMOVE it.

Answer

edit

There’s an Add-on available that removes the header or footer in the active document only once added:

Documents by Top Contributors

enter image description here

Goto your Google Document and choose from the menu Add-ons > Get add-ons… and search for:

enter image description here

Affiliation: I wrote the add-on


The following line of code will reset the header (gray line disappears).

Code

function onOpen() {
  DocumentApp.getUi().createMenu("Header / Footer")
    .addItem("Reset header", "resetHeader")
    .addItem("Reset footer", "resetFooter")
    .addToUi()
}

function resetHeader() {
  try {
    DocumentApp.getActiveDocument().getHeader().removeFromParent();
  } catch(e) {
    throw "No header present !!";
  }
}

function resetFooter() {
  try {
    DocumentApp.getActiveDocument().getFooter().removeFromParent();
  } catch(e) {
    throw "No footer present !!";
  }
}

Screenshot

before
enter image description here

after
enter image description here

Note

I’ve noticed that after running the script (and thus removing the header or footer), adding them wasn’t possible on the document I was working on.

Add the code under Tools > Script editor…, press the bug button to authenticate the script and then press the play button. This will “play” the code and reset the header.

edit
See Google Help Forum for an extensive walk-through: How to remove the header in Google Docs?

Attribution
Source : Link , Question Author : trex005 , Answer Author : Jacob Jan Tuinstra

Leave a Comment