Zengin metin bölgesini temsil eden bir öğe. Document içindeki tüm metinler Text öğeleri içinde yer alıyor.
Text öğesi Equation, Equation, List veya Paragraph içinde yer alabilir ancak kendisi başka bir öğe içeremez. Belge yapısı hakkında daha fazla bilgi için Google Dokümanlar'ı genişletme rehberine bakın.
// Gets the body contents of the active tab. const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Use editAsText to obtain a single text element containing // all the characters in the tab. const 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öntem | Dönüş türü | Kısa açıklama |
|---|---|---|
append | Text | Belirtilen metni bu metin bölgesinin sonuna ekler. |
copy() | Text | Geçerli öğenin ayrılmış, derin bir kopyasını döndürür. |
delete | Text | Bir metin aralığını siler. |
edit | Text | Düzenlemek için mevcut öğenin Text sürümünü alır. |
find | Range | Normal ifadeleri kullanarak öğenin içeriğinde belirtilen metin kalıbını arar. |
find | Range | Belirtilen metin kalıbını, belirli bir arama sonucundan başlayarak öğenin içeriğinde arar. |
get | Object | Öğenin özelliklerini alır. |
get | Object | Belirtilen karakter uzaklığındaki özellikleri alır. |
get | String|null | Arka plan rengi ayarını alır. |
get | String|null | Belirtilen karakter uzaklığındaki arka plan rengini alır. |
get | String|null | Yazı tipi ailesi ayarını alır. |
get | String|null | Belirtilen karakter uzaklığındaki yazı tipi ailesini alır. |
get | Number|null | Yazı tipi boyutu ayarını alır. |
get | Number|null | Belirtilen karakter uzaklığındaki yazı tipi boyutunu alır. |
get | String|null | Ön plan rengi ayarını alır. |
get | String|null | Belirtilen karakter uzaklığındaki ön plan rengini alır. |
get | String|null | Bağlantı URL'sini alır. |
get | String|null | Belirtilen karakter uzaklığındaki bağlantı URL'sini alır. |
get | Element|null | Öğenin sonraki kardeş öğesini alır. |
get | Container | Öğenin üst öğesini alır. |
get | Element|null | Öğenin önceki kardeş öğesini alır. |
get | String | Öğenin içeriğini metin dizesi olarak alır. |
get | Text | Metin hizalamasını alır. |
get | Text | Tek bir karakterin metin hizalamasını alır. |
get | Integer[] | Farklı metin biçimlendirme çalıştırmalarının başlangıcına karşılık gelen metin dizinleri kümesini alır. |
get | Element | Öğenin Element değerini alır. |
insert | Text | Belirtilen metni, verilen karakter uzaklığına ekler. |
is | Boolean | Öğenin Document sonunda olup olmadığını belirler. |
is | Boolean|null | Kalın ayarını alır. |
is | Boolean|null | Belirtilen karakter uzaklığındaki kalın ayarını alır. |
is | Boolean|null | İtalik ayarını alır. |
is | Boolean|null | Belirtilen karakter uzaklığındaki italik ayarını alır. |
is | Boolean|null | Üstü çizili ayarını alır. |
is | Boolean|null | Belirtilen karakter uzaklığındaki üstü çizili ayarını alır. |
is | Boolean|null | Altı çizili biçimlendirme ayarını alır. |
is | Boolean|null | Belirtilen karakter uzaklığındaki alt çizgi ayarını alır. |
merge() | Text|null | Öğeyi, aynı türdeki önceki kardeş öğeyle birleştirir. |
remove | Text|null | Öğeyi üst öğesinden kaldırır. |
replace | Element | Normal ifadeleri kullanarak belirli bir metin kalıbının tüm örneklerini belirli bir yeni dizeyle değiştirir. |
set | Text | Belirtilen özellikleri, verilen karakter aralığına uygular. |
set | Text | Öğenin özelliklerini ayarlar. |
set | Text | Belirtilen karakter aralığının arka plan rengini ayarlar. |
set | Text | Arka plan rengini ayarlar. |
set | Text | Kalın ayarını belirler. |
set | Text | Belirtilen karakter aralığı için kalın ayarını belirler. |
set | Text | Belirtilen karakter aralığı için yazı tipi ailesini ayarlar. |
set | Text | Yazı tipi ailesini ayarlar. |
set | Text | Belirtilen karakter aralığı için yazı tipi boyutunu ayarlar. |
set | Text | Yazı tipi boyutunu ayarlar. |
set | Text | Belirtilen karakter aralığı için ön plan rengini ayarlar. |
set | Text | Ön plan rengini ayarlar. |
set | Text | İtalik ayarını belirler. |
set | Text | Belirtilen karakter aralığı için italik ayarını belirler. |
set | Text | Belirtilen karakter aralığı için bağlantı URL'sini ayarlar. |
set | Text | Bağlantı URL'sini ayarlar. |
set | Text | Üstü çizili ayarını belirler. |
set | Text | Belirtilen karakter aralığı için üstü çizili ayarını belirler. |
set | Text | Metin içeriklerini ayarlar. |
set | Text | Belirli bir karakter aralığı için metin hizalamasını ayarlar. |
set | Text | Metin hizalamasını ayarlar. |
set | Text | Alt çizgi ayarını belirler. |
set | Text | Belirtilen karakter aralığı için alt çizgi ayarını belirler. |
Ayrıntılı belgeler
append Text(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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Adds the text, 'Sample body text,' to the end of the tab 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ı, aşağıdaki kapsamlardan biri 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 öğenin üst öğesi yok.
Return
Text: Yeni kopya.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
delete Text(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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Deletes the first 10 characters in the body. const text = body.editAsText().deleteText(0, 9);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
start | Integer | Silinecek ilk karakterin karakter uzaklığı. |
end | Integer | Silinecek son karakterin karakter uzaklığı. |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
edit As Text()
Düzenlemek için mevcut öğenin Text sürümünü alır.
Öğelerin içeriğini zengin metin olarak değiştirmek için edit kullanın. edit modu, metin olmayan öğeleri (ör. Inline ve Horizontal) yoksayar.
Silinen bir metin aralığında tamamen yer alan alt öğeler, öğeden kaldırılır.
const 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ü
find Text(searchPattern)
Normal ifadeleri kullanarak öğenin içeriğinde belirtilen metin kalıbını arar.
JavaScript normal ifade özelliklerinin bir alt kümesi (ör. yakalama grupları ve mod değiştiriciler) tam olarak desteklenmez.
Sağlanan normal ifade kalıbı, mevcut öğede bulunan her metin bloğuyla bağımsız olarak eşleştirilir.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
search | String | Aranacak desen |
Return
Range — arama metninin konumunu gösteren bir arama sonucu veya eşleşme yoksa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
find Text(searchPattern, from)
Belirtilen metin kalıbını, belirli bir arama sonucundan başlayarak öğenin içeriğinde arar.
JavaScript normal ifade özelliklerinin bir alt kümesi (ör. yakalama grupları ve mod değiştiriciler) tam olarak desteklenmez.
Sağlanan normal ifade kalıbı, mevcut öğede bulunan her metin bloğuyla bağımsız olarak eşleştirilir.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
search | String | Aranacak desen |
from | Range | Arama yapılacak arama sonucu |
Return
Range: Arama metninin bir sonraki konumunu gösteren bir arama sonucu veya eşleşme yoksa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Attributes()
Öğenin özelliklerini alır.
Sonuç, her geçerli öğe özelliği için bir özellik içeren bir nesnedir. Her özellik adı, Document numaralandırmasındaki bir öğeye karşılık gelir.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Append a styled paragraph. const par = body.appendParagraph('A bold, italicized paragraph.'); par.setBold(true); par.setItalic(true); // Retrieve the paragraph's attributes. const atts = par.getAttributes(); // Log the paragraph attributes. for (const att in atts) { Logger.log(`${att}:${atts[att]}`); }
Return
Object: Öğenin özellikleri.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Attributes(offset)
Belirtilen karakter uzaklığındaki özellikleri alır.
Sonuç, her geçerli metin özelliği için bir özellik içeren bir nesnedir. Her özellik adı, Document 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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
offset | Integer | Karakter ofseti. |
Return
Object: Öğenin özellikleri.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Background Color()
Arka plan rengi ayarını alır.
Return
String|null: CSS gösterimiyle (ör. '#ffffff') biçimlendirilmiş arka plan rengi veya öğe bu özellik için birden fazla değer içeriyorsa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Background Color(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/DOCUMENT_ID', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
offset | Integer | Karakter ofseti. |
Return
String|null: CSS gösterimiyle ('#ffffff' gibi) biçimlendirilmiş arka plan rengi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Font Family()
Yazı tipi ailesi ayarını alır. Ad, Dokümanlar'daki Yazı Tipi menüsünde veya Google Fonts'ta yer alan herhangi bir yazı tipi olabilir ve büyük/küçük harfe duyarlıdır. get ve set yöntemleri artık enum'ı yerine yazı tipleri için dize adları kullanıyor. Bu enum desteği sonlandırılmış olsa da eski komut dosyalarıyla uyumluluğu korumak için kullanılmaya devam edecektir.Font
Return
String|null: Yazı tipi ailesi veya öğe bu özellik için birden fazla değer içeriyorsa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Font Family(offset)
Belirtilen karakter uzaklığındaki yazı tipi ailesini alır. Ad, Dokümanlar'daki Yazı tipi menüsünde veya Google Fonts'ta yer alan herhangi bir yazı tipi olabilir ve büyük/küçük harfe duyarlıdır. get ve set yöntemleri artık enum'ı yerine yazı tipleri için dize adları kullanıyor. Bu enum desteği sonlandırılmış olsa da eski komut dosyalarıyla uyumluluğu korumak için kullanılmaya devam edecektir.
Font
// 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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
offset | Integer | Karakter ofseti. |
Return
String|null: Yazı tipi ailesi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Font Size()
Yazı tipi boyutu ayarını alır.
Return
Number|null: Yazı tipi boyutu veya öğe bu özellik için birden fazla değer içeriyorsa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Font Size(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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
offset | Integer | Karakter ofseti. |
Return
Number|null: Yazı tipi boyutu.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Foreground Color()
Ön plan rengi ayarını alır.
Return
String|null: CSS gösterimiyle ('#ffffff' gibi) biçimlendirilmiş veya öğe bu özellik için birden fazla değer içeriyorsa boş (null) olan ön plan rengi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Foreground Color(offset)
Belirtilen karakter uzaklığındaki ö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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
offset | Integer | Karakter ofseti. |
Return
String|null: CSS gösterimiyle (ör. '#ffffff') biçimlendirilmiş ön plan rengi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Link Url()
Bağlantı URL'sini alır.
Return
String|null: 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 biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Link Url(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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
offset | Integer | Karakter ofseti. |
Return
String|null: Bağlantı URL'si.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Next Sibling()
Öğenin sonraki kardeş öğesini alır.
Bir sonraki kardeş öğe, aynı üst öğeye sahiptir ve geçerli öğeyi takip eder.
Return
Element|null: Sonraki kardeş öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Parent()
Öğenin üst öğesini alır.
Üst öğe, geçerli öğeyi içerir.
Return
Container: Üst öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Previous Sibling()
Öğenin önceki kardeş öğesini alır.
Önceki kardeş öğe, aynı üst öğeye sahiptir ve geçerli öğeden önce gelir.
Return
Element|null: Önceki kardeş öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text()
Öğ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ı, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text Alignment()
Metin hizalamasını alır. Kullanılabilir hizalama türleri Document, Document ve Document'dir.
Return
Text: Metin hizalama türü veya metin birden fazla metin hizalama türü içeriyorsa ya da metin hizalama hiç ayarlanmamışsa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text Alignment(offset)
Tek bir karakterin metin hizalamasını alır. Kullanılabilir hizalama türleri Document, Document ve Document'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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
offset | Integer | Karakterin uzaklığı. |
Return
Text: Metin hizalamasının türü veya metin hizalaması hiç ayarlanmamışsa null.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text Attribute Indices()
Farklı metin biçimlendirme çalıştırmalarının başlangıcına karşılık gelen metin dizinleri kümesini 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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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 kümesi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Type()
Öğenin Element değerini alır.
Belirli bir öğenin tam türünü belirlemek için get kullanın.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Obtain the first element in the active tab's body. const 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
Element: Öğe türü.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insert Text(offset, text)
Belirtilen metni, verilen karakter uzaklığı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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
offset | Integer | Metnin ekleneceği karakter uzaklığı. |
text | String | Eklenecek metin. |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is At Document End()
Öğenin Document sonunda olup olmadığını belirler.
Return
Boolean: Öğenin sekmenin sonunda olup olmadığı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Bold()
Kalın ayarını alır.
Return
Boolean|null: Metnin kalın olup olmadığı veya öğe bu özellik için birden fazla değer içeriyorsa boş
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Bold(offset)
Belirtilen karakter uzaklığındaki kalın 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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
offset | Integer | Karakter ofseti. |
Return
Boolean|null: Kalın ayarı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Italic()
İtalik ayarını alır.
Return
Boolean|null: Metnin italik olup olmadığı veya öğe bu özellik için birden fazla değer içeriyorsa boş
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Italic(offset)
Belirtilen karakter uzaklığındaki 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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
offset | Integer | Karakter ofseti. |
Return
Boolean|null: İtalik ayarı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Strikethrough()
Üstü çizili ayarını alır.
Return
Boolean|null: Metnin üstü çizili olup olmadığı veya öğe bu özellik için birden fazla değer içeriyorsa boş
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Strikethrough(offset)
Belirtilen karakter uzaklığındaki ü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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
offset | Integer | Karakter ofseti. |
Return
Boolean|null: Üstü çizili ayarı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Underline()
Altı çizili biçimlendirme ayarını alır.
Return
Boolean|null: Metnin altı çizili olup olmadığı veya öğe bu özellik için birden fazla değer içeriyorsa boş
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Underline(offset)
Belirtilen karakter uzaklığındaki 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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
offset | Integer | Karakter ofseti. |
Return
Boolean|null: Altı çizili ayarı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
merge()
Öğeyi, aynı türdeki önceki kardeş öğeyle birleştirir.
Yalnızca aynı Element öğeleri birleştirilebilir. Geçerli öğede bulunan tüm alt öğeler, önceki kardeş öğeye taşınır.
Mevcut öğe dokümandan kaldırılır.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Example 1: Merge paragraphs // Append two paragraphs to the document's active tab. const par1 = body.appendParagraph('Paragraph 1.'); const 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. const cells = [ ['Row 1, Cell 1', 'Row 1, Cell 2'], ['Row 2, Cell 1', 'Row 2, Cell 2'], ]; // Build a table from the array. const table = body.appendTable(cells); // Get the first row in the table. const row = table.getRow(0); // Get the two cells in this row. const cell1 = row.getCell(0); const cell2 = row.getCell(1); // Merge the current cell into its preceding sibling element. const merged = cell2.merge();
Return
Text|null: Birleştirilmiş öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
remove From Parent()
Öğeyi üst öğesinden kaldırır.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Remove all images in the active tab's body. const imgs = body.getImages(); for (let i = 0; i < imgs.length; i++) { imgs[i].removeFromParent(); }
Return
Text|null: Kaldırılan öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
replace Text(searchPattern, replacement)
Normal ifadeleri kullanarak belirli bir metin kalıbının tüm örneklerini belirli bir yeni dizeyle değiştirir.
Arama kalıbı, JavaScript normal ifade nesnesi olarak değil, dize olarak iletilir. Bu nedenle, desendeki tüm ters eğik çizgileri çıkış karakteriyle belirtmeniz gerekir.
Bu yöntem, desteklenen söz dizimini sınırlayan Google'ın RE2 normal ifade kitaplığını kullanır.
Sağlanan normal ifade kalıbı, mevcut öğede bulunan her metin bloğuyla bağımsız olarak eşleştirilir.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Clear the text surrounding "Apps Script", with or without text. body.replaceText('^.*Apps ?Script.*$', 'Apps Script');
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
search | String | Aranacak normal ifade kalıbı |
replacement | String | Değiştirme için kullanılacak metin |
Return
Element: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Attributes(startOffset, endOffsetInclusive, attributes)
Belirtilen özellikleri, verilen karakter aralığına uygular.
Belirtilen özellikler parametresi, her özellik adının Document 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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
start | Integer | Metin aralığının başlangıç ofseti. |
end | Integer | Metin aralığının bitiş uzaklığı. |
attributes | Object | Öğenin özellikleri. |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Attributes(attributes)
Öğenin özelliklerini ayarlar.
Belirtilen özellikler parametresi, her özellik adının Document numaralandırmasındaki bir öğe ve her özellik değerinin uygulanacak yeni değer olduğu bir nesne olmalıdır.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Define a custom paragraph style. const 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. const 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ı, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Background Color(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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
start | Integer | Metin aralığının başlangıç ofseti. |
end | Integer | Metin aralığının bitiş uzaklığı. |
color | String | CSS gösterimiyle (ör. '#ffffff') biçimlendirilmiş arka plan rengi. |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Background Color(color)
Arka plan rengini ayarlar.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
color | String | CSS gösterimiyle biçimlendirilmiş arka plan rengi (ör. '#ffffff') |
Return
Text: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Bold(bold)
Kalın ayarını belirler.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
bold | Boolean | kalın ayarı |
Return
Text: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Bold(startOffset, endOffsetInclusive, bold)
Belirtilen karakter aralığı için kalın 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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the first 11 characters in the tab's body to bold. const text = body.editAsText().setBold(0, 10, true);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
start | Integer | Metin aralığının başlangıç ofseti. |
end | Integer | Metin aralığının bitiş uzaklığı. |
bold | Boolean | Kalın ayarı. |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Font Family(startOffset, endOffsetInclusive, fontFamilyName)
Belirtilen karakter aralığı için yazı tipi ailesini ayarlar. Ad, Dokümanlar'daki Yazı Tipi menüsünde veya Google Fonts'ta yer alan herhangi bir yazı tipi olabilir ve büyük/küçük harfe duyarlıdır.
Tanınmayan yazı tipi adları Arial olarak oluşturulur. get ve set yöntemleri artık enum'ı yerine yazı tipleri için dize adları kullanıyor. Bu enum desteği sonlandırılmış olsa da eski komut dosyalarıyla uyumluluğu korumak için kullanılmaya devam edecektir.
Font
// 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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
start | Integer | Metin aralığının başlangıç ofseti. |
end | Integer | Metin aralığının bitiş uzaklığı. |
font | String | Dokümanlar'daki Yazı Tipi menüsünde veya Google Fonts'ta yazı tipi ailesinin adı. |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Font Family(fontFamilyName)
Yazı tipi ailesini ayarlar. Ad, Dokümanlar'daki Yazı Tipi menüsünde veya Google Fonts'ta yer alan herhangi bir yazı tipi olabilir ve büyük/küçük harfe duyarlıdır. Tanınmayan yazı tipi adları Arial olarak oluşturulur. get ve set yöntemleri artık enum'ı yerine yazı tipleri için dize adları kullanıyor. Bu enum desteği sonlandırılmış olsa da eski komut dosyalarıyla uyumluluğu korumak için kullanılmaya devam edecektir.Font
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
font | String | Dokümanlar'daki Yazı Tipi menüsünde veya Google Fonts'ta yazı tipi ailesinin adı |
Return
Text: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Font Size(startOffset, endOffsetInclusive, size)
Belirtilen karakter aralığı için 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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
start | Integer | Metin aralığının başlangıç ofseti. |
end | Integer | Metin aralığının bitiş uzaklığı. |
size | Number | Yazı tipi boyutu. |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Font Size(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ı, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Foreground Color(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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').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
| Ad | Tür | Açıklama |
|---|---|---|
start | Integer | Metin aralığının başlangıç ofseti. |
end | Integer | Metin aralığının bitiş uzaklığı. |
color | String | CSS gösterimiyle biçimlendirilmiş ön plan rengi (ör. '#ffffff'). |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Foreground Color(color)
Ön plan rengini ayarlar.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
color | String | CSS gösterimiyle biçimlendirilmiş ön plan rengi (ör. '#ffffff') |
Return
Text: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Italic(italic)
İtalik ayarını belirler.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
italic | Boolean | italik ayarı |
Return
Text: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Italic(startOffset, endOffsetInclusive, italic)
Belirtilen karakter aralığı için italik 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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the first 11 characters in the tab's body to italic. const text = body.editAsText().setItalic(0, 10, true);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
start | Integer | Metin aralığının başlangıç ofseti. |
end | Integer | Metin aralığının bitiş uzaklığı. |
italic | Boolean | İtalik ayarı. |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Link Url(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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().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 |
|---|---|---|
start | Integer | Metin aralığının başlangıç ofseti. |
end | Integer | Metin aralığının bitiş uzaklığı. |
url | String | Bağlantı URL'si. |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Link Url(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ı, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Strikethrough(strikethrough)
Üstü çizili ayarını belirler.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
strikethrough | Boolean | üstü çizili ayarı |
Return
Text: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Strikethrough(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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the first 11 characters in the tab's body to strikethrough. const text = body.editAsText().setStrikethrough(0, 10, true);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
start | Integer | Metin aralığının başlangıç ofseti. |
end | Integer | Metin aralığının bitiş uzaklığı. |
strikethrough | Boolean | Üstü çizili ayarı. |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Text(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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().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ı, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Text Alignment(startOffset, endOffsetInclusive, textAlignment)
Belirli bir karakter aralığı için metin hizalamasını ayarlar. Kullanılabilir hizalama türleri şunlardır: Document, Document ve Document.
// Make the first character in the first paragraph of the active tab be // superscript. const documentTab = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab(); const text = documentTab.getBody().getParagraphs()[0].editAsText(); text.setTextAlignment(0, 0, DocumentApp.TextAlignment.SUPERSCRIPT);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
start | Integer | Karakter aralığının başlangıç ofseti. |
end | Integer | Karakter aralığının bitiş uzaklığı (dahil). |
text | Text | Uygulanacak metin hizalama türü. |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Text Alignment(textAlignment)
Metin hizalamasını ayarlar. Kullanılabilir hizalama türleri Document, Document ve Document'dir.
// Make the entire first paragraph in the active tab be superscript. const documentTab = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab(); const text = documentTab.getBody().getParagraphs()[0].editAsText(); text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
text | Text | Uygulanacak metin hizalama türü |
Return
Text: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Underline(underline)
Alt çizgi ayarını belirler.
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
underline | Boolean | altı çizili ayarı |
Return
Text: Geçerli öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Underline(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/DOCUMENT_ID/edit', ); // Gets the body contents of the tab by its ID. // TODO(developer): Replace the ID with your own. const body = doc.getTab('123abc').asDocumentTab().getBody(); // Sets the first 11 characters in the tab's body to underline. const text = body.editAsText().setUnderline(0, 10, true);
Parametreler
| Ad | Tür | Açıklama |
|---|---|---|
start | Integer | Metin aralığının başlangıç ofseti. |
end | Integer | Metin aralığının bitiş uzaklığı. |
underline | Boolean | Altı çizili ayarı. |
Return
Text: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan biri veya daha fazlasıyla yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents