Google apps script Google Docs API将字体背景设置为透明
如何使用Google Docs API将背景色设置为透明。我可以将背景设置为特定颜色,即“aa00aa”。但是,我不知道如何将其设置为透明。例如,假设您有:Google apps script Google Docs API将字体背景设置为透明,google-apps-script,google-api,Google Apps Script,Google Api,如何使用Google Docs API将背景色设置为透明。我可以将背景设置为特定颜色,即“aa00aa”。但是,我不知道如何将其设置为透明。例如,假设您有: function myTypes() { var selection = DocumentApp.getActiveDocument().getSelection(); if (selection) { var elements = selection.getRangeElements(); for (var
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");
}
}
}}
}
函数myTypes(){
var selection=DocumentApp.getActiveDocument().getSelection();
如果(选择){
var elements=selection.getRangeElements();
对于(var i=0;i
对我有效的是使用rgba代码,例如
rgba(255, 255, 255, 1);
您可以使用最后一个标准设置透明度;0表示完全透明,1表示不透明。因此,您应该执行以下操作以使背景透明:
text.setBackgroundColor("rgba(0, 0, 0, 0)");
对我有效的是使用rgba代码,例如
rgba(255, 255, 255, 1);
您可以使用最后一个标准设置透明度;0表示完全透明,1表示不透明。因此,您应该执行以下操作以使背景透明:
text.setBackgroundColor("rgba(0, 0, 0, 0)");
我发现use可以只使用术语“null”而不加引号
text.setBackgroundColor(null);
我发现use可以只使用术语“null”而不加引号
text.setBackgroundColor(null);