Zengin metin bölgesini temsil eden bir öğe. Bir Document
içindeki tüm metinler Text
öğelerinin içinde bulunur.
Text
öğesi Equation
, EquationFunction
, ListItem
veya Paragraph
içinde bulunabilir ancak başka herhangi bir öğe içeremez. Doküman yapısı hakkında daha fazla bilgi edinmek için Google Dokümanlar'ı genişletme kılavuzuna bakın.
var body = DocumentApp.getActiveDocument().getBody(); // Use editAsText to obtain a single text element containing // all the characters in the document. var text = body.editAsText(); // Insert text at the beginning of the document. text.insertText(0, 'Inserted text.\n'); // Insert text at the end of the document. text.appendText('\nAppended text.'); // Make the first half of the document blue. text.setForegroundColor(0, text.getText().length / 2, '#00FFFF');
Yöntemler
Yöntem | Dönüş türü | Kısa açıklama |
---|---|---|
appendText(text) | Text | Belirtilen metni bu metin bölgesinin sonuna ekler. |
copy() | Text | Geçerli öğenin ayrı ve derin bir kopyasını döndürür. |
deleteText(startOffset, endOffsetInclusive) | Text | Metin aralığını siler. |
editAsText() | Text | Düzenlemek için geçerli öğenin Text sürümünü alır. |
findText(searchPattern) | RangeElement | Normal ifadeler kullanarak belirtilen metin kalıbı için öğenin içeriğinde arama yapar. |
findText(searchPattern, from) | RangeElement | Belirli bir arama sonucundan itibaren öğenin içeriğini belirtilen metin kalıbı için arar. |
getAttributes() | Object | Öğenin özelliklerini alır. |
getAttributes(offset) | Object | Belirtilen karakter farkındaki özellikleri getirir. |
getBackgroundColor() | String | Arka plan renk ayarını alır. |
getBackgroundColor(offset) | String | Belirtilen karakter ofsetinde arka plan rengini alır. |
getFontFamily() | String | Yazı tipi ailesi ayarını alır. |
getFontFamily(offset) | String | Belirtilen karakter farkında yazı tipi ailesini getirir. |
getFontSize() | Number | Yazı tipi boyutu ayarını alır. |
getFontSize(offset) | Number | Belirtilen karakter farkındaki yazı tipi boyutunu alır. |
getForegroundColor() | String | Ön plan renk ayarını alır. |
getForegroundColor(offset) | String | Belirtilen karakter ofsetinde ön plan rengini alır. |
getLinkUrl() | String | Bağlantı URL'sini alır. |
getLinkUrl(offset) | String | Belirtilen karakter farkında bağlantı URL'sini alır. |
getNextSibling() | Element | Öğenin sonraki kardeş öğesini alır. |
getParent() | ContainerElement | Öğenin üst öğesini alır. |
getPreviousSibling() | Element | Öğenin önceki kardeş öğesini alır. |
getText() | String | Öğenin içeriğini metin dizesi olarak alır. |
getTextAlignment() | TextAlignment | Metin hizalamasını alır. |
getTextAlignment(offset) | TextAlignment | Tek bir karakterin metin hizalamasını alır. |
getTextAttributeIndices() | Integer[] | Ayrı metin biçimlendirme çalıştırmalarının başlangıcına karşılık gelen metin dizini grubunu alır. |
getType() | ElementType | Öğenin ElementType değerini alır. |
insertText(offset, text) | Text | Belirtilen metni belirtilen karakter farkına ekler. |
isAtDocumentEnd() | Boolean | Öğenin, Document öğesinin sonunda olup olmadığını belirler. |
isBold() | Boolean | Kalın ayarını alır. |
isBold(offset) | Boolean | Belirtilen karakter farkında kalın ayarı alır. |
isItalic() | Boolean | İtalik ayarını getirir. |
isItalic(offset) | Boolean | Belirtilen karakter farkı karşısında italik ayarını getirir. |
isStrikethrough() | Boolean | Üstü çizili ayarını getirir. |
isStrikethrough(offset) | Boolean | Belirtilen karakter ofsetinde üstü çizili ayarı alır. |
isUnderline() | Boolean | Altı çizili ayarını alır. |
isUnderline(offset) | Boolean | Belirtilen karakter ofsetinde altı çizili ayarını getirir. |
merge() | Text | Öğeyi, aynı türden önceki kardeş öğeyle birleştirir. |
removeFromParent() | Text | Öğeyi üst öğesinden kaldırır. |
replaceText(searchPattern, replacement) | Element | Normal ifadeler kullanarak, belirli bir metin kalıbının tüm tekrarlarını belirli bir değiştirme dizesiyle değiştirir. |
setAttributes(startOffset, endOffsetInclusive, attributes) | Text | Belirtilen özellikleri belirtilen karakter aralığına uygular. |
setAttributes(attributes) | Text | Öğenin özelliklerini ayarlar. |
setBackgroundColor(startOffset, endOffsetInclusive, color) | Text | Belirtilen karakter aralığının arka plan rengini ayarlar. |
setBackgroundColor(color) | Text | Arka plan rengini ayarlar. |
setBold(bold) | Text | Kalın ayarını yapar. |
setBold(startOffset, endOffsetInclusive, bold) | Text | Belirtilen karakter aralığı için kalın ayarı yapar. |
setFontFamily(startOffset, endOffsetInclusive, fontFamilyName) | Text | Belirtilen karakter aralığının yazı tipi ailesini ayarlar. |
setFontFamily(fontFamilyName) | Text | Yazı tipi ailesini ayarlar. |
setFontSize(startOffset, endOffsetInclusive, size) | Text | Belirtilen karakter aralığının yazı tipi boyutunu ayarlar. |
setFontSize(size) | Text | Yazı tipi boyutunu ayarlar. |
setForegroundColor(startOffset, endOffsetInclusive, color) | Text | Belirtilen karakter aralığının ön plan rengini ayarlar. |
setForegroundColor(color) | Text | Ön plan rengini ayarlar. |
setItalic(italic) | Text | İtalik ayarını yapar. |
setItalic(startOffset, endOffsetInclusive, italic) | Text | Belirtilen karakter aralığı için italik ayarını yapar. |
setLinkUrl(startOffset, endOffsetInclusive, url) | Text | Belirtilen karakter aralığının bağlantı URL'sini ayarlar. |
setLinkUrl(url) | Text | Bağlantı URL'sini ayarlar. |
setStrikethrough(strikethrough) | Text | Üstü çizili ayarını belirtir. |
setStrikethrough(startOffset, endOffsetInclusive, strikethrough) | Text | Belirtilen karakter aralığı için üstü çizilir ayarı yapar. |
setText(text) | Text | Metin içeriğini ayarlar. |
setTextAlignment(startOffset, endOffsetInclusive, textAlignment) | Text | Belirli bir karakter aralığı için metin hizalamasını ayarlar. |
setTextAlignment(textAlignment) | Text | Metin hizalamasını ayarlar. |
setUnderline(underline) | Text | Altı çizili ayarını ayarlar. |
setUnderline(startOffset, endOffsetInclusive, underline) | Text | Belirtilen karakter aralığı için altı çizili ayarı yapar. |
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 document body. const body = doc.getBody(); // Adds the text, 'Sample body text,' to the end of the document body. const text = body.editAsText().appendText('Sample body text');
Parametreler
Ad | Tür | Açıklama |
---|---|---|
text | String | Eklenecek metin. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
copy()
Geçerli öğenin ayrı ve derin bir kopyasını döndürür.
Öğede bulunan tüm alt öğeler de kopyalanır. Yeni öğenin üst öğesi yoktur.
Return
Text
- Yeni kopya.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
deleteText(startOffset, endOffsetInclusive)
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 document body. const body = doc.getBody(); // Deletes the first 10 characters in the body. const text = body.editAsText().deleteText(0, 9);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
startOffset | Integer | Silinecek ilk karakterin karakter göreli konumu. |
endOffsetInclusive | Integer | Silinecek son karakterin karakter göreli konumu. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
editAsText()
Düzenlemek için geçerli öğenin Text
sürümünü alır.
Öğe içeriğini zengin metin olarak değiştirmek için editAsText
kullanın. editAsText
modu, metin olmayan öğeleri (ör. InlineImage
ve HorizontalRule
) yok sayar.
Tamamen silinmiş bir metin aralığında bulunan alt öğeler öğeden kaldırılır.
var body = DocumentApp.getActiveDocument().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 bir metin sürümü
findText(searchPattern)
Normal ifadeler kullanarak belirtilen metin kalıbı için öğenin içeriğinde arama yapar.
Yakalama grupları ve mod değiştiriciler gibi JavaScript normal ifade özelliklerinin bir alt kümesi tam olarak desteklenmez.
Sağlanan normal ifade kalıbı, geçerli öğede yer alan her bir metin bloğuyla bağımsız olarak eşleştirilir.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
searchPattern | String | aranacak kalıp |
Return
RangeElement
: Arama metninin konumunu belirten bir arama sonucudur veya eşleşme yoksa boştur
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findText(searchPattern, from)
Belirli bir arama sonucundan itibaren öğenin içeriğini belirtilen metin kalıbı için arar.
Yakalama grupları ve mod değiştiriciler gibi JavaScript normal ifade özelliklerinin bir alt kümesi tam olarak desteklenmez.
Sağlanan normal ifade kalıbı, geçerli öğede yer alan her bir metin bloğuyla bağımsız olarak eşleştirilir.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
searchPattern | String | aranacak kalıp |
from | RangeElement | arama yapılacak arama sonucu |
Return
RangeElement
: Arama metninin sonraki konumunu belirten bir arama sonucudur veya eşleşme yoksa boştur
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getAttributes()
Öğenin özelliklerini alır.
Sonuç olarak, geçerli her öğe özelliği için bir özellik içeren ve her mülk adının DocumentApp.Attribute
sıralamasındaki bir öğeye karşılık geldiği bir nesne elde edilir.
var body = DocumentApp.getActiveDocument().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ı için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getAttributes(offset)
Belirtilen karakter farkındaki özellikleri getirir.
Sonuç olarak, her özellik adının DocumentApp.Attribute
sıralamasındaki bir öğeye karşılık geldiği geçerli her metin özelliği için bir özellik içeren bir nesne elde edilir.
// 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 document body. const body = doc.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 document 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
Ad | Tür | Açıklama |
---|---|---|
offset | Integer | Karakter göreli konumu. |
Return
Object
: Öğenin özellikleri.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getBackgroundColor()
Arka plan renk ayarını alır.
Return
String
: CSS gösterimi biçiminde biçimlendirilmiş arka plan rengi ('#ffffff'
gibi) veya öğe bu özellik için birden çok değer içeriyorsa boştur
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getBackgroundColor(offset)
Belirtilen karakter ofsetinde 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 document body. const body = doc.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
Ad | Tür | Açıklama |
---|---|---|
offset | Integer | Karakter göreli konumu. |
Return
String
- CSS notasyonunda biçimlendirilmiş ('#ffffff'
gibi) arka plan rengi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getFontFamily()
Yazı tipi ailesi ayarını alır. Ad, Dokümanlar'daki veya Google Fonts'taki Yazı tipi menüsünden herhangi bir yazı tipi olabilir ve büyük/küçük harfe duyarlıdır. getFontFamily()
ve setFontFamily(fontFamilyName)
yöntemleri artık
sıralama yerine yazı tipleri için dize adlarını kullanıyor. Bu sıralama kullanımdan kaldırılmış olsa da eski komut dosyalarıyla uyumlu olmaya devam edecektir.FontFamily
Return
String
: Yazı tipi ailesi veya öğe bu özellik için birden fazla değer içeriyorsa boş
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getFontFamily(offset)
Belirtilen karakter farkında yazı tipi ailesini getirir. Ad, Dokümanlar veya Google Fonts'taki Yazı tipi menüsünden herhangi bir yazı tipi olabilir ve büyük/küçük harfe duyarlıdır. getFontFamily()
ve setFontFamily(fontFamilyName)
yöntemlerinde artık yazı tipleri için
sıralama yerine dize adları kullanılıyor. Bu sıralama kullanımdan kaldırılmış olsa da eski komut dosyalarıyla uyumlu olmaya devam edecektir.
FontFamily
// 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 document body. const body = doc.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 document body. const fontFamily = text.getFontFamily(15); // Logs the font family to the console. console.log(fontFamily);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
offset | Integer | Karakter göreli konumu. |
Return
String
- Yazı tipi ailesi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
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 fazla değer içeriyorsa boş
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getFontSize(offset)
Belirtilen karakter farkı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 document body. const body = doc.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
Ad | Tür | Açıklama |
---|---|---|
offset | Integer | Karakter göreli konumu. |
Return
Number
: Yazı tipi boyutu.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getForegroundColor()
Ön plan renk ayarını alır.
Return
String
: CSS notasyonunda biçimlendirilmiş ('#ffffff'
gibi) ön plan rengi veya öğe, bu özellik için birden çok değer içeriyorsa boştur
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getForegroundColor(offset)
Belirtilen karakter ofsetinde ö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 document body. const body = doc.getBody(); // Sets the foreground color of the first 3 characters in the document body. const text = body.editAsText().setForegroundColor(0, 2, '#0000FF'); // Gets the foreground color of the first character in the document body. const foregroundColor = text.getForegroundColor(0); // Logs the foreground color to the console. console.log(foregroundcolor);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
offset | Integer | Karakter göreli konumu. |
Return
String
- CSS gösterimi biçiminde biçimlendirilmiş ön plan rengi ('#ffffff'
gibi).
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
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ı için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getLinkUrl(offset)
Belirtilen karakter farkında 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 document body. const body = doc.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
Ad | Tür | Açıklama |
---|---|---|
offset | Integer | Karakter göreli konumu. |
Return
String
- Bağlantı URL'si.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getNextSibling()
Öğenin sonraki kardeş öğesini alır.
Sonraki kardeş aynı üst öğeye sahip ve geçerli öğeyi takip ediyor.
Return
Element
- Sonraki kardeş öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
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çerir.
Return
ContainerElement
: Üst öğedir.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getPreviousSibling()
Öğenin önceki kardeş öğesini alır.
Önceki kardeş aynı üst öğeye sahip ve geçerli öğeden önce.
Return
Element
- Önceki kardeş öğesi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getText()
Öğenin içeriğini metin dizesi olarak alır.
Return
String
- öğenin metin dizesi olarak içeriği
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getTextAlignment()
Metin hizalamasını alır. Kullanılabilir hizalama türleri DocumentApp.TextAlignment.NORMAL
, DocumentApp.TextAlignment.SUBSCRIPT
ve DocumentApp.TextAlignment.SUPERSCRIPT
'dir.
Return
TextAlignment
: Metin hizalama türü veya metin birden fazla metin hizalama türü içeriyorsa veya metin hizalama hiç ayarlanmamışsa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getTextAlignment(offset)
Tek bir karakterin metin hizalamasını alır. Kullanılabilir hizalama türleri DocumentApp.TextAlignment.NORMAL
, DocumentApp.TextAlignment.SUBSCRIPT
ve DocumentApp.TextAlignment.SUPERSCRIPT
'dir.
// 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 document body. const body = doc.getBody(); // Sets the text alignment of the document 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
Ad | Tür | Açıklama |
---|---|---|
offset | Integer | Karakterin ofseti. |
Return
TextAlignment
: Metin hizalama türü veya metin hizalaması daha önce hiç ayarlanmamışsa null
.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getTextAttributeIndices()
Ayrı metin biçimlendirme çalıştırmalarının başlangıcına karşılık gelen metin dizini grubunu 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 document body. const body = doc.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.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
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 body = DocumentApp.getActiveDocument().getBody(); // Obtain the first element in the document 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ı için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertText(offset, text)
Belirtilen metni belirtilen karakter farkına 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 document body. const body = doc.getBody(); // Inserts the text, 'Sample inserted text', at the start of the body content. const text = body.editAsText().insertText(0, 'Sample inserted text');
Parametreler
Ad | Tür | Açıklama |
---|---|---|
offset | Integer | Metnin ekleneceği karakter ofseti. |
text | String | Eklenecek metin. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
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 dokümanın sonunda olup olmadığı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isBold()
Kalın ayarını alır.
Return
Boolean
: metnin kalın olup olmadığı veya öğe bu özellik için birden çok değer içeriyorsa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isBold(offset)
Belirtilen karakter farkında kalın ayarı 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 document body. const body = doc.getBody(); // Bolds the first 4 characters in the document 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
Ad | Tür | Açıklama |
---|---|---|
offset | Integer | Karakter göreli konumu. |
Return
Boolean
- Kalın ayar.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isItalic()
İtalik ayarını getirir.
Return
Boolean
: Metnin italik olup olmadığı veya öğe bu özellik için birden fazla değer içeriyorsa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isItalic(offset)
Belirtilen karakter farkı karşısında italik ayarını getirir.
// 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 document body. const body = doc.getBody(); // Sets the first 13 characters of the document body to italic. const text = body.editAsText().setItalic(0, 12, true); // Gets whether the fifth character in the document body is set to // italic and logs it to the console. const italic = text.isItalic(4); console.log(italic);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
offset | Integer | Karakter göreli konumu. |
Return
Boolean
: İtalik ayarı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isStrikethrough()
Üstü çizili ayarını getirir.
Return
Boolean
: Metnin üstü çizilir veya öğe bu özellik için birden fazla değer içeriyorsa null (boş değer)
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isStrikethrough(offset)
Belirtilen karakter ofsetinde üstü çizili ayarı 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 document body. const body = doc.getBody(); // Sets the first 17 characters of the document body to strikethrough. const text = body.editAsText().setStrikethrough(0, 16, true); // Gets whether the first character in the document body is set to // strikethrough and logs it to the console. const strikethrough = text.isStrikethrough(0); console.log(strikethrough);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
offset | Integer | Karakter göreli konumu. |
Return
Boolean
: Üstü çizili ayar.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isUnderline()
Altı çizili ayarını alır.
Return
Boolean
: Metnin altı çizili olup olmadığı veya öğe bu özellik için birden fazla değer içeriyorsa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isUnderline(offset)
Belirtilen karakter ofsetinde altı çizili ayarını getirir.
// 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 document body. const body = doc.getBody(); // Sets the first 13 characters of the document body to underline. const text = body.editAsText().setUnderline(0, 12, false); // Gets whether the first character in the document body is set to // underline and logs it to the console const underline = text.editAsText().isUnderline(0); console.log(underline);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
offset | Integer | Karakter göreli konumu. |
Return
Boolean
: Altı çizili ayar.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
merge()
Öğeyi, aynı türden önceki kardeş öğeyle birleştirir.
Yalnızca aynı ElementType
öğesinin öğeleri birleştirilebilir. Geçerli öğede bulunan tüm alt öğeler önceki kardeş öğeye taşınır.
Geçerli öğe dokümandan kaldırıldı.
var body = DocumentApp.getActiveDocument().getBody(); // Example 1: Merge paragraphs // Append two paragraphs to the document. 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ştirilen öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
removeFromParent()
Öğeyi üst öğesinden kaldırır.
var body = DocumentApp.getActiveDocument().getBody(); // Remove all images in the document 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ı için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
replaceText(searchPattern, replacement)
Normal ifadeler kullanarak, belirli bir metin kalıbının tüm tekrarlarını belirli bir değiştirme dizesiyle değiştirir.
Arama modeli, JavaScript normal ifade nesnesi olarak değil dize olarak iletilir. Bu nedenle, desendeki ters eğik çizgilerden kaçınmanız gerekir.
Bu yöntem, Google'ın desteklenen söz dizimini sınırlayan RE2 normal ifade kitaplığını kullanır.
Sağlanan normal ifade kalıbı, geçerli öğede yer alan her bir metin bloğuyla bağımsız olarak eşleştirilir.
var body = DocumentApp.getActiveDocument().getBody(); // Clear the text surrounding "Apps Script", with or without text. body.replaceText("^.*Apps ?Script.*$", "Apps Script");
Parametreler
Ad | Tür | Açıklama |
---|---|---|
searchPattern | String | için normal ifade kalıbı |
replacement | String | bunun yerine kullanılan metin |
Return
Element
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
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 özellik parametresi, her bir özellik adının DocumentApp.Attribute
numaralandırmasındaki bir öğe ve her özellik değerinin uygulanacak yeni değer olduğu bir nesne olmalıdı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 document body and edits as text. const body = doc.getBody().editAsText(); // 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 document body. const text = body.setAttributes(0, 8, style);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
startOffset | Integer | Metin aralığının başlangıç ofseti. |
endOffsetInclusive | Integer | Metin aralığının bitiş ofseti. |
attributes | Object | Öğenin özellikleri. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setAttributes(attributes)
Öğenin özelliklerini ayarlar.
Belirtilen özellik parametresi, her bir özellik adının DocumentApp.Attribute
numaralandırmasındaki bir öğe ve her özellik değerinin uygulanacak yeni değer olduğu bir nesne olmalıdır.
var body = DocumentApp.getActiveDocument().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
Ad | Tür | Açıklama |
---|---|---|
attributes | Object | Öğenin özellikleri. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setBackgroundColor(startOffset, endOffsetInclusive, color)
Belirtilen karakter aralığının 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 document body. const body = doc.getBody(); // Sets the background color of the first 3 characters in the // document body to hex color #0000FF. const text = body.editAsText().setBackgroundColor(0, 2, '#0000FF');
Parametreler
Ad | Tür | Açıklama |
---|---|---|
startOffset | Integer | Metin aralığının başlangıç ofseti. |
endOffsetInclusive | Integer | Metin aralığının bitiş ofseti. |
color | String | CSS notasyonunda ('#ffffff' gibi) biçimlendirilmiş arka plan rengi. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setBackgroundColor(color)
Arka plan rengini ayarlar.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
color | String | CSS gösterimi biçiminde biçimlendirilmiş arka plan rengi ('#ffffff' gibi) |
Return
Text
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setBold(bold)
Kalın ayarını yapar.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
bold | Boolean | kalın ayarı |
Return
Text
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setBold(startOffset, endOffsetInclusive, bold)
Belirtilen karakter aralığı için kalın ayarı 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 document body. const body = doc.getBody(); // Sets the first 11 characters in the document body to bold. const text = body.editAsText().setBold(0, 10, true);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
startOffset | Integer | Metin aralığının başlangıç ofseti. |
endOffsetInclusive | Integer | Metin aralığının bitiş ofseti. |
bold | Boolean | Kalın ayar. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setFontFamily(startOffset, endOffsetInclusive, fontFamilyName)
Belirtilen karakter aralığının yazı tipi ailesini ayarlar. Ad, Dokümanlar veya Google Fonts'taki Yazı tipi menüsünden herhangi bir yazı tipi olabilir ve büyük/küçük harfe duyarlıdır.
Tanınmayan yazı tipi adları LTI olarak oluşturulur. getFontFamily(offset)
ve setFontFamily(fontFamilyName)
yöntemleri artık yazı tipleri için
sıralama yerine dize adlarını kullanıyor. Bu sıralama kullanımdan kaldırılmış olsa da eski komut dosyalarıyla uyumlu olmaya devam edecektir.
FontFamily
// 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 body of the document. const body = doc.getBody(); // Sets the font of the first 4 characters in the document body to Roboto. const text = body.editAsText().setFontFamily(0, 3, 'Roboto');
Parametreler
Ad | Tür | Açıklama |
---|---|---|
startOffset | Integer | Metin aralığının başlangıç ofseti. |
endOffsetInclusive | Integer | Metin aralığının bitiş ofseti. |
fontFamilyName | String | Dokü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ı için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setFontFamily(fontFamilyName)
Yazı tipi ailesini ayarlar. Ad, Dokümanlar'daki veya Google Fonts'taki Yazı tipi menüsünden herhangi bir yazı tipi olabilir ve büyük/küçük harfe duyarlıdır. Tanınmayan yazı tipi adları
sıfır olarak oluşturulur. getFontFamily()
ve setFontFamily(fontFamilyName)
yöntemleri artık yazı tipleri için
sıralama yerine dize adlarını kullanıyor. Bu sıralama kullanımdan kaldırılmış olsa da eski komut dosyalarıyla uyumlu olmaya devam edecektir.FontFamily
Parametreler
Ad | Tür | Açıklama |
---|---|---|
fontFamilyName | String | Dokü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ı için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
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 document body. const body = doc.getBody(); // Sets the size of the first 11 characters in the document body to 12. const text = body.editAsText().setFontSize(0, 10, 12);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
startOffset | Integer | Metin aralığının başlangıç ofseti. |
endOffsetInclusive | Integer | Metin aralığının bitiş ofseti. |
size | Number | Yazı tipi boyutu. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setFontSize(size)
Yazı tipi boyutunu ayarlar.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
size | Number | yazı tipi boyutu |
Return
Text
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setForegroundColor(startOffset, endOffsetInclusive, color)
Belirtilen karakter aralığının ö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 document body. const body = doc.getBody(); // Sets the foreground color of the first 2 characters in the // document body to hex color #FF0000. const text = body.editAsText().setForegroundColor(0, 1, '#FF0000'); // Gets the foreground color for the second character in the document body. const foregroundColor = text.getForegroundColor(1); // Logs the foreground color to the console. console.log(foregroundColor);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
startOffset | Integer | Metin aralığının başlangıç ofseti. |
endOffsetInclusive | Integer | Metin aralığının bitiş ofseti. |
color | String | CSS gösterimi biçiminde biçimlendirilmiş ön plan rengi ('#ffffff' gibi). |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setForegroundColor(color)
Ön plan rengini ayarlar.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
color | String | CSS gösterimi biçiminde biçimlendirilmiş ön plan rengi ('#ffffff' gibi) |
Return
Text
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setItalic(italic)
İtalik ayarını yapar.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
italic | Boolean | italik ayarı |
Return
Text
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
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 document body. const body = doc.getBody(); // Sets the first 11 characters in the document body to italic. const text = body.editAsText().setItalic(0, 10, true);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
startOffset | Integer | Metin aralığının başlangıç ofseti. |
endOffsetInclusive | Integer | Metin aralığının bitiş ofseti. |
italic | Boolean | İtalik ayarı. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setLinkUrl(startOffset, endOffsetInclusive, url)
Belirtilen karakter aralığının 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 document body. const body = doc.getBody(); // Applies a link to the first 11 characters in the body. const text = body.editAsText().setLinkUrl(0, 10, 'https://example.com');
Parametreler
Ad | Tür | Açıklama |
---|---|---|
startOffset | Integer | Metin aralığının başlangıç ofseti. |
endOffsetInclusive | Integer | Metin aralığının bitiş ofseti. |
url | String | Bağlantı URL'si. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setLinkUrl(url)
Bağlantı URL'sini ayarlar.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
url | String | bağlantı URL'si |
Return
Text
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setStrikethrough(strikethrough)
Üstü çizili ayarını belirtir.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
strikethrough | Boolean | üstü çizili ayarı |
Return
Text
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setStrikethrough(startOffset, endOffsetInclusive, strikethrough)
Belirtilen karakter aralığı için üstü çizilir ayarı 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 document body. const body = doc.getBody(); // Sets the first 11 characters in the document body to strikethrough. const text = body.editAsText().setStrikethrough(0, 10, true);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
startOffset | Integer | Metin aralığının başlangıç ofseti. |
endOffsetInclusive | Integer | Metin aralığının bitiş ofseti. |
strikethrough | Boolean | Üstü çizili ayar. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setText(text)
Metin içeriğini 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 document body. const body = doc.getBody(); // Replaces the contents of the body with the text, 'New body text.' const text = body.editAsText().setText('New body text.');
Parametreler
Ad | Tür | Açıklama |
---|---|---|
text | String | Yeni metin içerikleri. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
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 DocumentApp.TextAlignment.NORMAL
, DocumentApp.TextAlignment.SUBSCRIPT
ve DocumentApp.TextAlignment.SUPERSCRIPT
'dir.
// Make the first character in the first paragraph be superscript. var text = DocumentApp.getActiveDocument().getBody().getParagraphs()[0].editAsText(); text.setTextAlignment(0, 0, DocumentApp.TextAlignment.SUPERSCRIPT);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
startOffset | Integer | Karakter aralığının başlangıç ofseti. |
endOffsetInclusive | Integer | Karakter aralığının bitiş ofseti (dahil). |
textAlignment | TextAlignment | Uygulanacak metin hizalama türü. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setTextAlignment(textAlignment)
Metin hizalamasını ayarlar. Kullanılabilir hizalama türleri DocumentApp.TextAlignment.NORMAL
, DocumentApp.TextAlignment.SUBSCRIPT
ve DocumentApp.TextAlignment.SUPERSCRIPT
'dir.
// Make the entire first paragraph be superscript. var text = DocumentApp.getActiveDocument().getBody().getParagraphs()[0].editAsText(); text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
textAlignment | TextAlignment | uygulanacak metin hizalama türü |
Return
Text
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setUnderline(underline)
Altı çizili ayarını ayarlar.
Parametreler
Ad | Tür | Açıklama |
---|---|---|
underline | Boolean | altı çizili ayarı |
Return
Text
- geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setUnderline(startOffset, endOffsetInclusive, underline)
Belirtilen karakter aralığı için altı çizili ayarı 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 document body. const body = doc.getBody(); // Sets the first 11 characters in the document body to underline. const text = body.editAsText().setUnderline(0, 10, true);
Parametreler
Ad | Tür | Açıklama |
---|---|---|
startOffset | Integer | Metin aralığının başlangıç ofseti. |
endOffsetInclusive | Integer | Metin aralığının bitiş ofseti. |
underline | Boolean | Altı çizili metin ayarı. |
Return
Text
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları için aşağıdaki kapsamlardan en az birinin yetkilendirilmesi gerekir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents