Class Text

Metin

Zengin metin bölgesini temsil eden bir öğe. Document içindeki tüm metinler Text öğeleri içinde yer alır. Text öğesi; Equation, EquationFunction, ListItem veya Paragraph, ancak kendisi başka bir öğe içeremez. Daha fazla hakkında bilgi edinmek için Google Dokümanlar'ı genişletme kılavuzuna bakın.

// Gets the body contents of the active tab.
var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Use editAsText to obtain a single text element containing
// all the characters in the tab.
var text = body.editAsText();

// Insert text at the beginning of the tab.
text.insertText(0, 'Inserted text.\n');

// Insert text at the end of the tab.
text.appendText('\nAppended text.');

// Make the first half of the tab blue.
text.setForegroundColor(0, text.getText().length / 2, '#00FFFF');

Yöntemler

YöntemDönüş türüKısa açıklama
appendText(text)TextBelirtilen metni, bu metin bölgesinin sonuna ekler.
copy()TextGeçerli öğenin ayrılmış, derin bir kopyasını döndürür.
deleteText(startOffset, endOffsetInclusive)TextBir metin aralığını siler.
editAsText()TextDüzenleme için geçerli öğenin Text sürümünü alır.
findText(searchPattern)RangeElementNormal ifadeler kullanarak belirtilen metin kalıbı için öğenin içeriğinde arama yapar.
findText(searchPattern, from)RangeElementBelirli bir değerden başlayarak belirtilen metin kalıbı için öğenin içeriğinde arama yapar emin olun.
getAttributes()ObjectÖğenin özelliklerini alır.
getAttributes(offset)ObjectÖzellikleri, belirtilen karakter uzaklığında alır.
getBackgroundColor()StringArka plan rengi ayarını alır.
getBackgroundColor(offset)StringBelirtilen karakter uzaklığındaki arka plan rengini alır.
getFontFamily()StringYazı tipi ailesi ayarını alır.
getFontFamily(offset)StringBelirtilen karakter uzaklığındaki yazı tipi ailesini alır.
getFontSize()NumberYazı tipi boyutu ayarını alır.
getFontSize(offset)NumberBelirtilen karakter uzaklığındaki yazı tipi boyutunu alır.
getForegroundColor()StringÖn plan renk ayarını alır.
getForegroundColor(offset)StringBelirtilen karakter uzaklığında ön plan rengini alır.
getLinkUrl()StringBağlantı URL'sini alır.
getLinkUrl(offset)StringBelirtilen karakter uzaklığındaki bağlantı URL'sini alır.
getNextSibling()ElementÖğenin sonraki eşdüzey öğeyi alır.
getParent()ContainerElementÖğenin üst öğesini alır.
getPreviousSibling()ElementÖğenin önceki eşdüzey öğesini alır.
getText()StringÖğenin içeriğini bir metin dizesi olarak alır.
getTextAlignment()TextAlignmentMetin hizalamasını getirir.
getTextAlignment(offset)TextAlignmentTek bir karakter için metin hizalamasını alır.
getTextAttributeIndices()Integer[]Farklı metin biçimlendirmesinin başlangıcına karşılık gelen metin dizinleri grubunu alır koşar.
getType()ElementTypeÖğenin ElementType değerini alır.
insertText(offset, text)TextBelirtilen metni, belirtilen karakter uzaklığında ekler.
isAtDocumentEnd()BooleanÖğenin, Document öğesinin sonunda olup olmadığını belirler.
isBold()BooleanKalın yazı tipi ayarını alır.
isBold(offset)BooleanBelirtilen karakter uzaklığında kalın yazı tipi ayarını alır.
isItalic()Booleanİtalik ayarını alır.
isItalic(offset)BooleanBelirtilen karakter uzaklığında italik ayarını alır.
isStrikethrough()BooleanÜstü çizili ayarını alır.
isStrikethrough(offset)BooleanBelirtilen karakter uzaklığında üstü çizili ayarını alır.
isUnderline()BooleanAltı çizili ayarını alır.
isUnderline(offset)BooleanBelirtilen karakter uzaklığında alt çizgi ayarını alır.
merge()TextÖğeyi, aynı türden bir önceki kardeş öğeyle birleştirir.
removeFromParent()TextÖğeyi üst öğesinden kaldırır.
replaceText(searchPattern, replacement)ElementBelirli bir metin kalıbının tüm tekrarlarını, normal değer kullanarak belirli bir değiştirme dizesiyle değiştirir ifade eder.
setAttributes(startOffset, endOffsetInclusive, attributes)TextBelirtilen özellikleri, belirtilen karakter aralığına uygular.
setAttributes(attributes)TextÖğenin özelliklerini ayarlar.
setBackgroundColor(startOffset, endOffsetInclusive, color)TextBelirtilen karakter aralığı için arka plan rengini ayarlar.
setBackgroundColor(color)TextArka plan rengini ayarlar.
setBold(bold)TextKalın yazı tipi ayarını belirler.
setBold(startOffset, endOffsetInclusive, bold)TextBelirtilen karakter aralığı için kalın yazı tipi ayarını belirler.
setFontFamily(startOffset, endOffsetInclusive, fontFamilyName)TextBelirtilen karakter aralığı için yazı tipi ailesini ayarlar.
setFontFamily(fontFamilyName)TextYazı tipi ailesini ayarlar.
setFontSize(startOffset, endOffsetInclusive, size)TextBelirtilen karakter aralığının yazı tipi boyutunu ayarlar.
setFontSize(size)TextYazı tipi boyutunu ayarlar.
setForegroundColor(startOffset, endOffsetInclusive, color)TextBelirtilen karakter aralığı için ön plan rengini ayarlar.
setForegroundColor(color)TextÖn plan rengini ayarlar.
setItalic(italic)Textİtalik ayarını ayarlar.
setItalic(startOffset, endOffsetInclusive, italic)TextBelirtilen karakter aralığı için italik ayarını yapar.
setLinkUrl(startOffset, endOffsetInclusive, url)TextBelirtilen karakter aralığı için bağlantı URL'sini ayarlar.
setLinkUrl(url)TextBağlantı URL'sini ayarlar.
setStrikethrough(strikethrough)TextÜstü çizili ayarını ayarlar.
setStrikethrough(startOffset, endOffsetInclusive, strikethrough)TextBelirtilen karakter aralığı için üstü çizili ayarını belirler.
setText(text)TextMetin içeriklerini ayarlar.
setTextAlignment(startOffset, endOffsetInclusive, textAlignment)TextBelirli bir karakter aralığı için metin hizalamasını ayarlar.
setTextAlignment(textAlignment)TextMetin hizalamasını ayarlar.
setUnderline(underline)TextAltı çizili ayarını ayarlar.
setUnderline(startOffset, endOffsetInclusive, underline)TextBelirtilen karakter aralığı için alt çizgi ayarını belirler.

Ayrıntılı belgeler

appendText(text)

Belirtilen metni, bu metin bölgesinin sonuna ekler.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Adds the text, 'Sample body text,' to the end of the tab body.
const text = body.editAsText().appendText('Sample body text');

Parametreler

AdTürAçıklama
textStringEklenecek metin.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

copy()

Geçerli öğenin ayrılmış, derin bir kopyasını döndürür.

Öğede bulunan tüm alt öğeler de kopyalanır. Yeni öğede üst öğesidir.

Return

Text — Yeni kopya.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

deleteText(startOffset, endOffsetInclusive)

Bir metin aralığını siler.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Deletes the first 10 characters in the body.
 const text = body.editAsText().deleteText(0, 9);

Parametreler

AdTürAçıklama
startOffsetIntegerSilinecek ilk karakterin karakter uzaklığı.
endOffsetInclusiveIntegerSilinecek son karakterin karakter farkı.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

editAsText()

Düzenleme için geçerli öğenin Text sürümünü alır.

Öğe içeriklerini zengin metin olarak değiştirmek için editAsText kullanın. editAsText modu, metin olmayan öğeleri (InlineImage ve HorizontalRule gibi) yoksayar.

Silinmiş bir metin aralığında tamamen yer alan alt öğeler öğeden kaldırılır.

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Insert two paragraphs separated by a paragraph containing an
// horizontal rule.
body.insertParagraph(0, "An editAsText sample.");
body.insertHorizontalRule(0);
body.insertParagraph(0, "An example.");

// Delete " sample.\n\n An" removing the horizontal rule in the process.
body.editAsText().deleteText(14, 25);

Return

Text: Geçerli öğenin metin sürümü


findText(searchPattern)

Normal ifadeler kullanarak belirtilen metin kalıbı için öğenin içeriğinde arama yapar.

JavaScript normal ifade özelliklerinin bir alt kümesi tam olarak desteklenmiyor; örneğin, ve mod değiştiricileri yakalayabilirsiniz.

Sağlanan normal ifade kalıbı her metin bloğuyla bağımsız olarak eşleştirilir öğedir.

Parametreler

AdTürAçıklama
searchPatternStringaranacak kalıp

Return

RangeElement — arama metninin konumunu veya konumunu gösteren bir arama sonucu yoksa null denk gelmek

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

findText(searchPattern, from)

Belirli bir değerden başlayarak belirtilen metin kalıbı için öğenin içeriğinde arama yapar emin olun.

JavaScript normal ifade özelliklerinin bir alt kümesi tam olarak desteklenmiyor; örneğin, ve mod değiştiricileri yakalayabilirsiniz.

Sağlanan normal ifade kalıbı her metin bloğuyla bağımsız olarak eşleştirilir öğedir.

Parametreler

AdTürAçıklama
searchPatternStringaranacak kalıp
fromRangeElementarama sonuçlarında

Return

RangeElement — arama metninin sonraki konumunu gösteren bir arama sonucu veya denk gelmek

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getAttributes()

Öğenin özelliklerini alır.

Sonuç, her bir geçerli öğe özelliği için bir özellik içeren özellik adı, DocumentApp.Attribute numaralandırmasındaki bir öğeye karşılık gelir.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.getBody();

// Append a styled paragraph.
var par = body.appendParagraph('A bold, italicized paragraph.');
par.setBold(true);
par.setItalic(true);

// Retrieve the paragraph's attributes.
var atts = par.getAttributes();

// Log the paragraph attributes.
for (var att in atts) {
  Logger.log(att + ":" + atts[att]);
}

Return

Object: Öğenin özellikleri.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getAttributes(offset)

Özellikleri, belirtilen karakter uzaklığında alır.

Sonuç, her bir geçerli metin özelliği için bir özellik içeren bir nesnedir; burada her özellik adı, DocumentApp.Attribute numaralandırmasındaki bir öğeye karşılık gelir.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Declares style attributes.
const style = {}
style[DocumentApp.Attribute.BOLD] = true;
style[DocumentApp.Attribute.ITALIC] = true;
style[DocumentApp.Attribute.FONT_SIZE] = 29;

// Sets the style attributes to the tab's body.
const text = body.editAsText();
text.setAttributes(style);

// Gets the style attributes applied to the eleventh character in the
// body and logs them to the console.
const attributes = text.getAttributes(10);
console.log(attributes);

Parametreler

AdTürAçıklama
offsetIntegerKarakter uzaklığı.

Return

Object: Öğenin özellikleri.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getBackgroundColor()

Arka plan rengi ayarını alır.

Return

String — CSS gösteriminde ('#ffffff' gibi) biçimlendirilmiş arka plan rengi veya null öğe bu özellik için birden fazla değer içeriyorsa

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getBackgroundColor(offset)

Belirtilen karakter uzaklığındaki arka plan rengini alır.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the background color of the first 3 characters in the body.
const text = body.editAsText().setBackgroundColor(0, 2, '#FFC0CB');

// Gets the background color of the first character in the body.
const backgroundColor = text.getBackgroundColor(0);

// Logs the background color to the console.
console.log(backgroundColor);

Parametreler

AdTürAçıklama
offsetIntegerKarakter uzaklığı.

Return

String — CSS gösteriminde biçimlendirilmiş arka plan rengi ('#ffffff' gibi).

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getFontFamily()

Yazı tipi ailesi ayarını alır. Ad, Dokümanlar veya Google Fonts'taki Yazı Tipi menüsünde bulunan herhangi bir yazı tipi olabilir ve büyük/küçük harfe duyarlıdır. getFontFamily() ve setFontFamily(fontFamilyName) yöntemleri artık yazı tipleri için FontFamily sıralaması. Bu sıralama kullanımdan kaldırıldığında eski komut dosyalarıyla uyumluluk için kullanılabilecektir.

Return

String: Yazı tipi ailesi; öğe bu özellik için birden çok değer içeriyorsa null

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getFontFamily(offset)

Belirtilen karakter uzaklığındaki yazı tipi ailesini alır. Ad, Dokümanlar veya Google Fonts'taki yazı tipi menüsü ve büyük/küçük harfe duyarlıdır. getFontFamily() ve setFontFamily(fontFamilyName) yöntemleri artık yazı tipleri için FontFamily sıralaması yerine dize adları kullanılır. Bu sıralama kullanımdan kaldırıldığında eski komut dosyalarıyla uyumluluk için kullanılabilecektir.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the font of the first 16 characters to Impact.
const text = body.editAsText().setFontFamily(0, 15, 'Impact');

// Gets the font family of the 16th character in the tab body.
const fontFamily = text.getFontFamily(15);

// Logs the font family to the console.
console.log(fontFamily);

Parametreler

AdTürAçıklama
offsetIntegerKarakter uzaklığı.

Return

String — Yazı tipi ailesi.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getFontSize()

Yazı tipi boyutu ayarını alır.

Return

Number: Yazı tipi boyutu veya öğe bu özellik için birden çok değer içeriyorsa null

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getFontSize(offset)

Belirtilen karakter uzaklığındaki yazı tipi boyutunu alır.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the font size of the first 13 characters to 15.
const text = body.editAsText().setFontSize(0, 12, 15);

// Gets the font size of the first character.
const fontSize = text.getFontSize(0);

// Logs the font size to the console.
console.log(fontSize);

Parametreler

AdTürAçıklama
offsetIntegerKarakter uzaklığı.

Return

Number: Yazı tipi boyutu.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getForegroundColor()

Ön plan renk ayarını alır.

Return

String — CSS gösteriminde ('#ffffff' gibi) biçimlendirilmiş ön plan rengi veya null öğe bu özellik için birden fazla değer içeriyorsa

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getForegroundColor(offset)

Belirtilen karakter uzaklığında ön plan rengini alır.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the foreground color of the first 3 characters in the tab body.
const text = body.editAsText().setForegroundColor(0, 2, '#0000FF');

// Gets the foreground color of the first character in the tab body.
const foregroundColor = text.getForegroundColor(0);

// Logs the foreground color to the console.
console.log(foregroundcolor);

Parametreler

AdTürAçıklama
offsetIntegerKarakter uzaklığı.

Return

String - CSS gösteriminde biçimlendirilmiş ön plan rengi ('#ffffff' gibi).

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getLinkUrl()

Bağlantı URL'sini alır.

Return

String: bağlantı URL'si veya öğe bu özellik için birden fazla değer içeriyorsa null

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getLinkUrl(offset)

Belirtilen karakter uzaklığındaki bağlantı URL'sini alır.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Applies a link to the first 10 characters in the body.
const text = body.editAsText().setLinkUrl(0, 9, 'https://www.example.com/');

// Gets the URL of the link from the first character.
const link = text.getLinkUrl(0);

// Logs the link URL to the console.
console.log(link);

Parametreler

AdTürAçıklama
offsetIntegerKarakter uzaklığı.

Return

String: Bağlantı URL'si.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getNextSibling()

Öğenin sonraki eşdüzey öğeyi alır.

Sonraki kardeş öğe, aynı üst öğeye sahiptir ve geçerli öğeyi takip eder.

Return

Element: Sonraki kardeş öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getParent()

Öğenin üst öğesini alır.

Üst öğe, geçerli öğeyi içeriyor.

Return

ContainerElement: Üst öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getPreviousSibling()

Öğenin önceki eşdüzey öğesini alır.

Önceki eşdüzey öğe, aynı üst öğeye sahip ve geçerli öğeden önce geliyor.

Return

Element: Önceki kardeş öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getText()

Öğenin içeriğini bir metin dizesi olarak alır.

Return

String: Metin dizesi olarak öğenin içeriği

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getTextAlignment()

Metin hizalamasını getirir. Kullanılabilir hizalama türleri şunlardır: DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT ve DocumentApp.TextAlignment.SUPERSCRIPT.

Return

TextAlignment: Metin hizalamasının türü veya metin birden fazla metin türü içeriyorsa null veya metin hizalaması hiç ayarlanmamışsa

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getTextAlignment(offset)

Tek bir karakter için metin hizalamasını alır. Kullanılabilir hizalama türleri şunlardır: DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT ve DocumentApp.TextAlignment.SUPERSCRIPT.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the text alignment of the tab's body to NORMAL.
const text = body.editAsText().setTextAlignment(DocumentApp.TextAlignment.NORMAL);

// Gets the text alignment of the ninth character.
const alignment = text.getTextAlignment(8);

// Logs the text alignment to the console.
console.log(alignment.toString());

Parametreler

AdTürAçıklama
offsetIntegerKarakterin uzaklığı.

Return

TextAlignment: Metin hizalamasının türü veya metin hizalaması hiç ayarlanmamışsa null.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getTextAttributeIndices()

Farklı metin biçimlendirmesinin başlangıcına karşılık gelen metin dizinleri grubunu alır koşar.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Gets the text indices at which text formatting changes.
const indices = body.editAsText().getTextAttributeIndices();

// Logs the indices to the console.
console.log(indices.toString());

Return

Integer[] — Metin biçimlendirmesinin değiştiği metin dizinleri grubu.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getType()

Öğenin ElementType değerini alır.

Belirli bir öğenin tam türünü belirlemek için getType() işlevini kullanın.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.getBody();

// Obtain the first element in the active tab's body.

var firstChild = body.getChild(0);

// Use getType() to determine the element's type.
if (firstChild.getType() == DocumentApp.ElementType.PARAGRAPH) {
  Logger.log('The first element is a paragraph.');
} else {
  Logger.log('The first element is not a paragraph.');
}

Return

ElementType: Öğe türü.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

insertText(offset, text)

Belirtilen metni, belirtilen karakter uzaklığında ekler.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Inserts the text, 'Sample inserted text', at the start of the body content.
const text = body.editAsText().insertText(0, 'Sample inserted text');

Parametreler

AdTürAçıklama
offsetIntegerMetnin ekleneceği karakter uzaklığı.
textStringEklenecek metin.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

isAtDocumentEnd()

Öğenin, Document öğesinin sonunda olup olmadığını belirler.

Return

Boolean — Öğenin sekmenin sonunda olup olmadığı.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

isBold()

Kalın yazı tipi ayarını alır.

Return

Boolean - Metnin kalın olup olmadığı veya öğe bu değer için birden fazla değer içeriyorsa boş olup olmadığı ilişkilendirmek

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

isBold(offset)

Belirtilen karakter uzaklığında kalın yazı tipi ayarını alır.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Bolds the first 4 characters in the tab body.
const text = body.editAsText().setBold(0, 3, true);

// Gets whether or not the text is bold.
const bold = text.editAsText().isBold(0);

// Logs the text's bold setting to the console
console.log(bold);

Parametreler

AdTürAçıklama
offsetIntegerKarakter uzaklığı.

Return

Boolean — Kalın yazı tipi ayarı.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

isItalic()

İtalik ayarını alır.

Return

Boolean: Metnin italik olup olmadığı veya öğe bu değer için birden fazla değer içeriyorsa boş olup olmadığı ilişkilendirmek

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

isItalic(offset)

Belirtilen karakter uzaklığında italik ayarını alır.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the first 13 characters of the tab body to italic.
const text = body.editAsText().setItalic(0, 12, true);

// Gets whether the fifth character in the tab body is set to
// italic and logs it to the console.
const italic = text.isItalic(4);
console.log(italic);

Parametreler

AdTürAçıklama
offsetIntegerKarakter uzaklığı.

Return

Boolean — İtalik ayarı.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

isStrikethrough()

Üstü çizili ayarını alır.

Return

Boolean: Metnin üstü çizili olup olmadığı veya öğede birden çok değer varsa boş olup olmadığı bu özellik

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

isStrikethrough(offset)

Belirtilen karakter uzaklığında üstü çizili ayarını alır.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the first 17 characters of the tab body to strikethrough.
const text = body.editAsText().setStrikethrough(0, 16, true);

// Gets whether the first character in the tab body is set to
// strikethrough and logs it to the console.
const strikethrough = text.isStrikethrough(0);
console.log(strikethrough);

Parametreler

AdTürAçıklama
offsetIntegerKarakter uzaklığı.

Return

Boolean: Üstü çizili ayar.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

isUnderline()

Altı çizili ayarını alır.

Return

Boolean - metnin altının çizili olup olmadığı veya öğede birden çok değer varsa boş bu özellik

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

isUnderline(offset)

Belirtilen karakter uzaklığında alt çizgi ayarını alır.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the first 13 characters of the tab body to underline.
const text = body.editAsText().setUnderline(0, 12, false);

// Gets whether the first character in the tab body is set to
// underline and logs it to the console
const underline = text.editAsText().isUnderline(0);
console.log(underline);

Parametreler

AdTürAçıklama
offsetIntegerKarakter uzaklığı.

Return

Boolean — Altı çizili ayarı.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

merge()

Öğeyi, aynı türden bir önceki kardeş öğeyle birleştirir.

Yalnızca aynı ElementType öğesine ait öğeler birleştirilebilir. Şunda bulunan tüm alt öğeler: geçerli öğe önceki eşdüzey öğeye taşınır.

Geçerli öğe dokümandan kaldırılır.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.getBody();

// Example 1: Merge paragraphs
// Append two paragraphs to the document's active tab.
var par1 = body.appendParagraph('Paragraph 1.');
var par2 = body.appendParagraph('Paragraph 2.');
// Merge the newly added paragraphs into a single paragraph.
par2.merge();

// Example 2: Merge table cells
// Create a two-dimensional array containing the table's cell contents.
var cells = [
['Row 1, Cell 1', 'Row 1, Cell 2'],
['Row 2, Cell 1', 'Row 2, Cell 2']
];
// Build a table from the array.
var table = body.appendTable(cells);
// Get the first row in the table.
 var row = table.getRow(0);
// Get the two cells in this row.
var cell1 = row.getCell(0);
var cell2 = row.getCell(1);
// Merge the current cell into its preceding sibling element.
var merged = cell2.merge();

Return

Text: Birleştirilmiş öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

removeFromParent()

Öğeyi üst öğesinden kaldırır.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab()
var body = documentTab.getBody();

// Remove all images in the active tab's body.
var imgs = body.getImages();
for (var i = 0; i < imgs.length; i++) {
  imgs[i].removeFromParent();
}

Return

Text: Kaldırılan öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

replaceText(searchPattern, replacement)

Belirli bir metin kalıbının tüm tekrarlarını, normal değer kullanarak belirli bir değiştirme dizesiyle değiştirir ifade eder.

Arama kalıbı, JavaScript normal ifade nesnesi değil, dize olarak iletilir. Bu nedenle, kalıptaki ters eğik çizgilerden kaçınmanız gerekir.

Bu yöntemler, Google'ın normal RE2 desteklenen söz dizimini sınırlayan ifade kitaplığı için kullanılır.

Sağlanan normal ifade kalıbı her metin bloğuyla bağımsız olarak eşleştirilir öğedir.

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Clear the text surrounding "Apps Script", with or without text.
body.replaceText("^.*Apps ?Script.*$", "Apps Script");

Parametreler

AdTürAçıklama
searchPatternStringaranacak normal ifade kalıbı
replacementStringyerine kullanılacak metin

Return

Element - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setAttributes(startOffset, endOffsetInclusive, attributes)

Belirtilen özellikleri, belirtilen karakter aralığına uygular.

Belirtilen özellikler parametresi, her özellik adının DocumentApp.Attribute sıralaması ve her özellik değeri, geçerlidir.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Declares style attributes for font size and font family.
const style = {}
style[DocumentApp.Attribute.FONT_SIZE] = 20 ;
style[DocumentApp.Attribute.FONT_FAMILY] = 'Impact';

// Sets the style attributes to the first 9 characters in the tab's body.
const text = body.setAttributes(0, 8, style);

Parametreler

AdTürAçıklama
startOffsetIntegerMetin aralığının başlangıç uzaklığı.
endOffsetInclusiveIntegerMetin aralığının bitiş uzaklığı.
attributesObjectÖğenin özellikleri.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setAttributes(attributes)

Öğenin özelliklerini ayarlar.

Belirtilen özellikler parametresi, her özellik adının DocumentApp.Attribute sıralaması ve her özellik değeri, geçerlidir.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.getBody();

// Define a custom paragraph style.
var style = {};
style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] =
    DocumentApp.HorizontalAlignment.RIGHT;
style[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri';
style[DocumentApp.Attribute.FONT_SIZE] = 18;
style[DocumentApp.Attribute.BOLD] = true;

// Append a plain paragraph.
var par = body.appendParagraph('A paragraph with custom style.');

// Apply the custom style.
par.setAttributes(style);

Parametreler

AdTürAçıklama
attributesObjectÖğenin özellikleri.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setBackgroundColor(startOffset, endOffsetInclusive, color)

Belirtilen karakter aralığı için arka plan rengini ayarlar.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the background color of the first 3 characters in the
// tab body to hex color #0000FF.
const text = body.editAsText().setBackgroundColor(0, 2, '#0000FF');

Parametreler

AdTürAçıklama
startOffsetIntegerMetin aralığının başlangıç uzaklığı.
endOffsetInclusiveIntegerMetin aralığının bitiş uzaklığı.
colorStringCSS gösteriminde biçimlendirilmiş arka plan rengi ('#ffffff' gibi).

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setBackgroundColor(color)

Arka plan rengini ayarlar.

Parametreler

AdTürAçıklama
colorStringCSS gösteriminde biçimlendirilmiş arka plan rengi ('#ffffff' gibi)

Return

Text - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setBold(bold)

Kalın yazı tipi ayarını belirler.

Parametreler

AdTürAçıklama
boldBooleankalın ayarı

Return

Text - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setBold(startOffset, endOffsetInclusive, bold)

Belirtilen karakter aralığı için kalın yazı tipi ayarını belirler.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the first 11 characters in the tab's body to bold.
const text = body.editAsText().setBold(0, 10, true);

Parametreler

AdTürAçıklama
startOffsetIntegerMetin aralığının başlangıç uzaklığı.
endOffsetInclusiveIntegerMetin aralığının bitiş uzaklığı.
boldBooleanKalın yazı tipi ayarı.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setFontFamily(startOffset, endOffsetInclusive, fontFamilyName)

Belirtilen karakter aralığı için yazı tipi ailesini ayarlar. Ad, Yazı Tipi'ndeki herhangi bir yazı tipi olabilir Google Fonts'ta yer alan bir menüdür ve büyük/küçük harfe duyarlıdır. Tanınmayan yazı tipi adları GPC olarak oluşturulur. getFontFamily(offset) ve setFontFamily(fontFamilyName) artık yazı tipleri için FontFamily sıralaması yerine dize adlarını kullanıyor. Bu sıralama kullanımdan kaldırıldığında eski komut dosyalarıyla uyumluluk için kullanılabilecektir.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the font of the first 4 characters in the tab's body to Roboto.
const text = body.editAsText().setFontFamily(0, 3, 'Roboto');

Parametreler

AdTürAçıklama
startOffsetIntegerMetin aralığının başlangıç uzaklığı.
endOffsetInclusiveIntegerMetin aralığının bitiş uzaklığı.
fontFamilyNameStringDokümanlar veya Google Fonts'taki Yazı Tipi menüsünden yazı tipi ailesinin adı.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setFontFamily(fontFamilyName)

Yazı tipi ailesini ayarlar. Ad, Dokümanlar veya Google Fonts'taki Yazı Tipi menüsünde bulunan herhangi bir yazı tipi olabilir ve büyük/küçük harfe duyarlıdır. Tanınmayan yazı tipi adları GPC olarak görüntülenir. getFontFamily() ve setFontFamily(fontFamilyName) yöntemleri artık yazı tipleri için FontFamily sıralaması yerine dize adlarını kullanıyor. Bu sıralama kullanımdan kaldırıldığında eski komut dosyalarıyla uyumluluk için kullanılabilecektir.

Parametreler

AdTürAçıklama
fontFamilyNameStringDokümanlar veya Google Fonts'taki Yazı Tipi menüsünden yazı tipi ailesinin adı

Return

Text - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setFontSize(startOffset, endOffsetInclusive, size)

Belirtilen karakter aralığının yazı tipi boyutunu ayarlar.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the size of the first 11 characters in the tab's body to 12.
const text = body.editAsText().setFontSize(0, 10, 12);

Parametreler

AdTürAçıklama
startOffsetIntegerMetin aralığının başlangıç uzaklığı.
endOffsetInclusiveIntegerMetin aralığının bitiş uzaklığı.
sizeNumberYazı tipi boyutu.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setFontSize(size)

Yazı tipi boyutunu ayarlar.

Parametreler

AdTürAçıklama
sizeNumberyazı tipi boyutu

Return

Text - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setForegroundColor(startOffset, endOffsetInclusive, color)

Belirtilen karakter aralığı için ön plan rengini ayarlar.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the foreground color of the first 2 characters in the
// tab's body to hex color #FF0000.
const text = body.editAsText().setForegroundColor(0, 1, '#FF0000');

// Gets the foreground color for the second character in the tab's body.
const foregroundColor = text.getForegroundColor(1);

//  Logs the foreground color to the console.
console.log(foregroundColor);

Parametreler

AdTürAçıklama
startOffsetIntegerMetin aralığının başlangıç uzaklığı.
endOffsetInclusiveIntegerMetin aralığının bitiş uzaklığı.
colorStringCSS gösteriminde biçimlendirilmiş ön plan rengi (ör. '#ffffff').

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setForegroundColor(color)

Ön plan rengini ayarlar.

Parametreler

AdTürAçıklama
colorStringCSS gösteriminde biçimlendirilmiş ön plan rengi ('#ffffff' gibi)

Return

Text - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setItalic(italic)

İtalik ayarını ayarlar.

Parametreler

AdTürAçıklama
italicBooleanitalik ayarı

Return

Text - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setItalic(startOffset, endOffsetInclusive, italic)

Belirtilen karakter aralığı için italik ayarını yapar.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the first 11 characters in the tab's body to italic.
const text = body.editAsText().setItalic(0, 10, true);

Parametreler

AdTürAçıklama
startOffsetIntegerMetin aralığının başlangıç uzaklığı.
endOffsetInclusiveIntegerMetin aralığının bitiş uzaklığı.
italicBooleanİtalik ayarı.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setLinkUrl(startOffset, endOffsetInclusive, url)

Belirtilen karakter aralığı için bağlantı URL'sini ayarlar.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Applies a link to the first 11 characters in the body.
const text = body.editAsText().setLinkUrl(0, 10, 'https://example.com');

Parametreler

AdTürAçıklama
startOffsetIntegerMetin aralığının başlangıç uzaklığı.
endOffsetInclusiveIntegerMetin aralığının bitiş uzaklığı.
urlStringBağlantı URL'si.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setLinkUrl(url)

Bağlantı URL'sini ayarlar.

Parametreler

AdTürAçıklama
urlStringbağlantı URL'si

Return

Text - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setStrikethrough(strikethrough)

Üstü çizili ayarını ayarlar.

Parametreler

AdTürAçıklama
strikethroughBooleanüstü çizili ayarı

Return

Text - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setStrikethrough(startOffset, endOffsetInclusive, strikethrough)

Belirtilen karakter aralığı için üstü çizili ayarını belirler.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the first 11 characters in the tab's body to strikethrough.
const text = body.editAsText().setStrikethrough(0, 10, true);

Parametreler

AdTürAçıklama
startOffsetIntegerMetin aralığının başlangıç uzaklığı.
endOffsetInclusiveIntegerMetin aralığının bitiş uzaklığı.
strikethroughBooleanÜstü çizili ayarı.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setText(text)

Metin içeriklerini ayarlar.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Replaces the contents of the body with the text, 'New body text.'
const text = body.editAsText().setText('New body text.');

Parametreler

AdTürAçıklama
textStringYeni metin içerikleri.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setTextAlignment(startOffset, endOffsetInclusive, textAlignment)

Belirli bir karakter aralığı için metin hizalamasını ayarlar. Kullanılabilir hizalama türleri şunlardır: DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT ve DocumentApp.TextAlignment.SUPERSCRIPT.

// Make the first character in the first paragraph of the active tab be superscript.
var documentTab = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab();
var text = documentTab.getBody().getParagraphs()[0].editAsText();
text.setTextAlignment(0, 0, DocumentApp.TextAlignment.SUPERSCRIPT);

Parametreler

AdTürAçıklama
startOffsetIntegerKarakter aralığının başlangıç uzaklığı.
endOffsetInclusiveIntegerKarakter aralığının bitiş uzaklığı (bu değerler dahil).
textAlignmentTextAlignmentUygulanacak metin hizalamasının türü.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setTextAlignment(textAlignment)

Metin hizalamasını ayarlar. Kullanılabilir hizalama türleri şunlardır: DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT ve DocumentApp.TextAlignment.SUPERSCRIPT.

// Make the entire first paragraph in the active tab be superscript.
var documentTab = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab();
var text = documentTab.getBody().getParagraphs()[0].editAsText();
text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);

Parametreler

AdTürAçıklama
textAlignmentTextAlignmentuygulanacak metin hizalamasının türü

Return

Text - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setUnderline(underline)

Altı çizili ayarını ayarlar.

Parametreler

AdTürAçıklama
underlineBooleanaltı çizili ayarı

Return

Text - geçerli öğe

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setUnderline(startOffset, endOffsetInclusive, underline)

Belirtilen karakter aralığı için alt çizgi ayarını belirler.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl('https://docs.google.com/document/d/abc123456/edit');

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('t.0').asDocumentTab().getBody();

// Sets the first 11 characters in the tab's body to underline.
const text = body.editAsText().setUnderline(0, 10, true);

Parametreler

AdTürAçıklama
startOffsetIntegerMetin aralığının başlangıç uzaklığı.
endOffsetInclusiveIntegerMetin aralığının bitiş uzaklığı.
underlineBooleanAltı çizili ayarı.

Return

Text: Geçerli öğe.

Yetkilendirme

Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan bir veya daha fazlasıyla yetkilendirme gerektirir:

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents