Google Apps Script targeting header on doc with different first page headers -
i have simple little apps script refreshes our dynamic logo on request. problem can't target header if designer checks "different first page header/footer" checkbox. there away target different header if it's checked?
here code i'm using:
function onopen() { documentapp.getui().createmenu('branding') .additem('update branding', 'updatelogo') .addtoui(); } function updatelogo() { var doc = documentapp.getactivedocument(); var header = doc.getheader(); if (header) { var images = header.getimages(); var logowidth = 250; if (images.length > 0) { var image = images[0]; logowidth = image.getwidth(); // pixels image.removefromparent(); } var freshlogo = urlfetchapp.fetch("http://example.com/logo.jpg").getblob(); var newimage = header.insertimage(0, freshlogo); var logoratio = newimage.getheight() / newimage.getwidth(); newimage.setwidth(logowidth); newimage.setheight(newimage.getwidth() * logoratio); } }
unfortunately apps script's documentapp isn't aware of different first page header/footer setting. please file feature request here: https://code.google.com/p/google-apps-script-issues/issues/list
Comments
Post a Comment