Scans all paragraphs in the active Google Docs document.
Identifies headings (Heading 1 to Heading 6).
Resets their font sizes to predefined values.
Can be run manually or set as a trigger.
function resetHeadingSizes() { var doc = DocumentApp.getActiveDocument(); var body = doc.getBody(); var paragraphs = body.getParagraphs();
// Define default font sizes for headings var headingSizes = { [DocumentApp.ParagraphHeading.HEADING1]: 24, [DocumentApp.ParagraphHeading.HEADING2]: 20, [DocumentApp.ParagraphHeading.HEADING3]: 18, [DocumentApp.ParagraphHeading.HEADING4]: 16, [DocumentApp.ParagraphHeading.HEADING5]: 14, [DocumentApp.ParagraphHeading.HEADING6]: 12 };
// Iterate through paragraphs and reset heading sizes paragraphs.forEach(paragraph => { var heading = paragraph.getHeading(); if (heading in headingSizes) { paragraph.setFontSize(headingSizes[heading]); } });
Logger.log("Headings have been reset to default sizes."); }
How to Use:
Open a Google Docs document.
Click Extensions > Apps Script.
Copy and paste the script into the editor.
Click the Run button.
Authorize the script when prompted.
The script will reset all heading sizes in the document.