0
您如何将背景颜色设置为透明,使用Google Docs API。我可以将背景设置为特定颜色,即“#aa00aa”。但是,我不确定如何将其设置为透明。例如,假设您拥有:Google Docs API将透明字体背景设置为
function myTypes() {
var selection = DocumentApp.getActiveDocument().getSelection();
if (selection) {
var elements = selection.getRangeElements();
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
// Only modify elements that can be edited as text; skip images and other non-text elements.
if (element.getElement().editAsText) {
var text = element.getElement().editAsText();
// Edit the selected part of the element, or the full element if it's completely selected.
if (element.isPartial()) {
text.setFontSize(element.getStartOffset(), element.getEndOffsetInclusive(), 10);
text.setFontFamily(element.getStartOffset(), element.getEndOffsetInclusive(), "Consolas");
text.setForegroundColor(element.getStartOffset(), element.getEndOffsetInclusive(), "#cc0cc");
text.setBackgroundColor(element.getStartOffset(), element.getEndOffsetInclusive(), "#aa00aa");
} else {
text.setFontSize(10);
text.setFontFamily("Consolas");
text.setForegroundColor("#cc00cc");
text.setBackgroundColor("#aa00aa");
}
}
}}
}