Paragrafı temsil eden bir öğe. Paragraph
öğesi Equation
, Footnote
, HorizontalRule
, InlineDrawing
, InlineImage
, PageBreak
ve Text
öğelerini içerebilir. Doküman yapısı hakkında daha fazla bilgi edinmek için Google Dokümanlar'ı genişletme kılavuzuna göz atın.
Paragraphs
yeni satır karakterleri içeremez. Yeni satır karakterleri ("\n"), satır sonu karakterlerine ("ORDINAL") dönüştürülür.
var body = DocumentApp.getActiveDocument().getBody(); // Append a document header paragraph. var header = body.appendParagraph("A Document"); header.setHeading(DocumentApp.ParagraphHeading.HEADING1); // Append a section header paragraph. var section = body.appendParagraph("Section 1"); section.setHeading(DocumentApp.ParagraphHeading.HEADING2); // Append a regular paragraph. body.appendParagraph("This is a typical paragraph.");
Yöntemler
Yöntem | Dönüş türü | Kısa açıklama |
---|---|---|
addPositionedImage(image) | PositionedImage | Belirtilen resim blobundan yeni bir PositionedImage oluşturur ve ekler. |
appendHorizontalRule() | HorizontalRule | Yeni bir HorizontalRule oluşturur ve ekler. |
appendInlineImage(image) | InlineImage | Belirtilen resim blobundan yeni bir InlineImage oluşturur ve ekler. |
appendInlineImage(image) | InlineImage | Belirtilen InlineImage eklenir. |
appendPageBreak() | PageBreak | Yeni bir PageBreak oluşturur ve ekler. |
appendPageBreak(pageBreak) | PageBreak | Belirtilen PageBreak eklenir. |
appendText(text) | Text | Belirtilen içerikle yeni bir Text öğesi oluşturur ve ekler. |
appendText(text) | Text | Belirtilen Text öğesini ekler. |
clear() | Paragraph | Öğenin içeriğini temizler. |
copy() | Paragraph | Mevcut öğenin ayrılmış, derin bir kopyasını döndürür. |
editAsText() | Text | Düzenlemek için geçerli öğenin Text sürümünü alır. |
findElement(elementType) | RangeElement | Öğenin içeriğinde, belirtilen türde bir alt öğe arar. |
findElement(elementType, from) | RangeElement | Öğenin RangeElement alanında, belirtilen türden başlayarak belirtilen türde bir alt öğe arar. |
findText(searchPattern) | RangeElement | Normal ifadeler kullanarak öğenin içeriğini belirtilen metin kalıbı için arar. |
findText(searchPattern, from) | RangeElement | Belirli bir arama sonucundan başlayarak, öğenin içeriğinde belirtilen metin kalıbını arar. |
getAlignment() | HorizontalAlignment | HorizontalAlignment değerini alır. |
getAttributes() | Object | Öğenin özelliklerini alır. |
getChild(childIndex) | Element | Belirtilen alt dizindeki alt öğeyi alır. |
getChildIndex(child) | Integer | Belirtilen alt öğenin alt dizinini alır. |
getHeading() | ParagraphHeading | ParagraphHeading değerini alır. |
getIndentEnd() | Number | Uç girintiyi noktalar halinde alır. |
getIndentFirstLine() | Number | İlk satır girintisini noktalar halinde alır. |
getIndentStart() | Number | Başlangıç girintisini alır. |
getLineSpacing() | Number | Satır aralığını noktalar halinde alır. |
getLinkUrl() | String | Bağlantı URL'sini alır. |
getNextSibling() | Element | Öğenin sonraki kardeş öğesini alır. |
getNumChildren() | Integer | Alt öğelerin sayısını alır. |
getParent() | ContainerElement | Öğenin üst öğesini alır. |
getPositionedImage(id) | PositionedImage | Resmin kimliğine göre bir PositionedImage alır. |
getPositionedImages() | PositionedImage[] | Tüm PositionedImage paragraflarını paragrafa sabitler. |
getPreviousSibling() | Element | Öğenin önceki kardeş öğesini alır. |
getSpacingAfter() | Number | Öğeden sonraki boşluğu noktalar halinde alır. |
getSpacingBefore() | Number | Öğeden önceki boşluğu noktalar halinde alır. |
getText() | String | Öğenin içeriğini metin dizesi olarak alır. |
getTextAlignment() | TextAlignment | Metnin hizalamasını alır. |
getType() | ElementType | Öğenin ElementType özelliğini alır. |
insertHorizontalRule(childIndex) | HorizontalRule | Belirtilen dizinde bir HorizontalRule oluşturur ve ekler. |
insertInlineImage(childIndex, image) | InlineImage | Belirtilen dizinde yeni bir InlineImage oluşturur ve belirtilen dizine ekler. |
insertInlineImage(childIndex, image) | InlineImage | Belirtilen InlineImage öğesini, belirtilen dizine ekler. |
insertPageBreak(childIndex) | PageBreak | Belirtilen dizinde yeni bir PageBreak oluşturur ve ekler. |
insertPageBreak(childIndex, pageBreak) | PageBreak | Belirtilen PageBreak öğesini, belirtilen dizine ekler. |
insertText(childIndex, text) | Text | Belirtilen dizinde yeni bir metin öğesi oluşturur ve ekler. |
insertText(childIndex, text) | Text | Belirtilen Text öğesini, belirtilen dizin içeriğini belirtilen metin içerikleriyle ekler. |
isAtDocumentEnd() | Boolean | Öğenin, Document öğesinin sonunda olup olmadığını belirler. |
isLeftToRight() | Boolean | Soldan sağa ayarını alır. |
merge() | Paragraph | Öğeyi, aynı türde önceki kardeş öğeyle birleştirir. |
removeChild(child) | Paragraph | Belirtilen alt öğeyi kaldırır. |
removeFromParent() | Paragraph | Öğeyi üst öğesinden kaldırır. |
removePositionedImage(id) | Boolean | Resim kimliğine göre bir PositionedImage kaldırır. |
replaceText(searchPattern, replacement) | Element | Düzenli ifadeler kullanarak belirli bir metin kalıbının tüm tekrarlarını belirli bir değiştirme dizesiyle değiştirir. |
setAlignment(alignment) | Paragraph | HorizontalAlignment özelliğini ayarlar. |
setAttributes(attributes) | Paragraph | Öğenin özelliklerini ayarlar. |
setHeading(heading) | Paragraph | ParagraphHeading özelliğini ayarlar. |
setIndentEnd(indentEnd) | Paragraph | Bitiş girintisini noktalar halinde ayarlar. |
setIndentFirstLine(indentFirstLine) | Paragraph | İlk satır girintisini noktalar halinde ayarlar. |
setIndentStart(indentStart) | Paragraph | Başlangıç girintisini noktalar halinde ayarlar. |
setLeftToRight(leftToRight) | Paragraph | Soldan sağa ayarını belirler. |
setLineSpacing(multiplier) | Paragraph | Satır aralığını, aralık olarak kullanılacak satır sayısını belirten bir miktar olarak ayarlar. |
setLinkUrl(url) | Paragraph | Bağlantı URL'sini ayarlar. |
setSpacingAfter(spacingAfter) | Paragraph | Öğeden sonraki boşluğu noktalar halinde ayarlar. |
setSpacingBefore(spacingBefore) | Paragraph | Öğeden önceki boşluğu noktalar halinde ayarlar. |
setText(text) | void | Paragrafın içeriğini metin olarak ayarlar. |
setTextAlignment(textAlignment) | Paragraph | Metin hizalamasını ayarlar. |
Ayrıntılı dokümanlar
addPositionedImage(image)
Belirtilen resim blobundan yeni bir PositionedImage
oluşturur ve ekler.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('abc123456'); // Gets the document body. const body = doc.getBody(); // Gets the first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Fetches the specified image URL. const image = UrlFetchApp.fetch('https://fonts.gstatic.com/s/i/productlogos/apps_script/v10/web-24dp/logo_apps_script_color_1x_web_24dp.png'); // Adds the image to the document, anchored to the first paragraph. paragraph.addPositionedImage(image);
Parametreler
Ad | Type | Açıklama |
---|---|---|
image | BlobSource | Resim verileri. |
Return
PositionedImage
- Yeni konumlandırılmış resim.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendHorizontalRule()
Yeni bir HorizontalRule
oluşturur ve ekler.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('abc123456'); // Gets the document body. const body = doc.getBody(); // Gets the first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Adds a horizontal line under the first paragraph. paragraph.appendHorizontalRule();
Return
HorizontalRule
- Yeni yatay kural.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendInlineImage(image)
Belirtilen resim blobundan yeni bir InlineImage
oluşturur ve ekler.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('abc123456'); // Gets the document body. const body = doc.getBody(); // Gets the first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Fetches the image from the specified image URL. const image = UrlFetchApp .fetch('https://fonts.gstatic.com/s/i/productlogos/apps_script/v10/web-96dp/logo_apps_script_color_1x_web_96dp.png'); // Adds the image to the first paragraph. paragraph.appendInlineImage(image);
Parametreler
Ad | Type | Açıklama |
---|---|---|
image | BlobSource | Resim verileri. |
Return
InlineImage
- Eklenen resim.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendInlineImage(image)
Belirtilen InlineImage
eklenir.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('abc123456'); // Gets the document body. const body = doc.getBody(); // Gets the first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Makes a copy of the first image in the body. const image = body.getImages()[0].copy();; // Adds the image to the first paragraph. paragraph.appendInlineImage(image);
Parametreler
Ad | Type | Açıklama |
---|---|---|
image | InlineImage | Resim verileri. |
Return
InlineImage
- Eklenen resim.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendPageBreak()
Yeni bir PageBreak
oluşturur ve ekler.
Not: PageBreaks
, TableCells
içinde bulunamaz.
Geçerli öğe bir tablo hücresinde yer alıyorsa bir istisna atılır.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('abc123456'); // Gets the document body. const body = doc.getBody(); // Gets the first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Adds a page break after the first paragraph. paragraph.appendPageBreak();
Return
PageBreak
: Yeni sayfa sonu öğesi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendPageBreak(pageBreak)
Belirtilen PageBreak
eklenir.
Not: PageBreaks
, TableCells
içinde yer alamaz.
Mevcut öğe bir tablo hücresinde varsa komut dosyası bir istisna oluşturur.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('abc123456'); // Gets the document body. const body = doc.getBody(); // Gets the first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Adds a page break after the first paragraph. const pageBreak = paragraph.appendPageBreak(); // Makes a copy of the page break. const newPageBreak = pageBreak.copy(); // Adds the copied page break to the paragraph. paragraph.appendPageBreak(newPageBreak);
Parametreler
Ad | Type | Açıklama |
---|---|---|
pageBreak | PageBreak | Eklenecek sayfa sonu. |
Return
PageBreak
: Ekli sayfa sonu öğesi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendText(text)
Belirtilen içerikle yeni bir Text
öğesi oluşturur ve ekler.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('abc123456'); // Gets the document body. const body = doc.getBody(); // Gets the first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Adds a string to the paragraph. paragraph.appendText('This is a new sentence.');
Parametreler
Ad | Type | Açıklama |
---|---|---|
text | String | Metin içerikleri. |
Return
Text
- Yeni metin öğesi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
appendText(text)
Belirtilen Text
öğesini ekler.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('abc123456'); // Gets the document body. const body = doc.getBody(); // Gets the text from the first paragraph in the body. const paragraph1 = body.getParagraphs()[0]; const text = paragraph1.getText(); // Gets the third paragraph in the body. const paragraph3 = body.getParagraphs()[2]; // Adds the text from the first paragraph to the third paragraph. paragraph3.appendText(text);
Parametreler
Ad | Type | Açıklama |
---|---|---|
text | Text | Eklenecek metin öğesi. |
Return
Text
- Eklenen metin öğesi.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
clear()
copy()
Mevcut öğenin ayrılmış, derin bir kopyasını döndürür.
Öğede bulunan tüm alt öğeler de kopyalanır. Yeni öğenin üst öğesi yoktur.
Return
Paragraph
- Yeni kopya.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
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.
Öğelerin 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.
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 metin sürümü
findElement(elementType)
Öğenin içeriğinde, belirtilen türde bir alt öğe arar.
Parametreler
Ad | Type | Açıklama |
---|---|---|
elementType | ElementType | aranacak öğe türü |
Return
RangeElement
- Arama öğesinin konumunu gösteren bir arama sonucu
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findElement(elementType, from)
Öğenin RangeElement
alanında, belirtilen türden başlayarak belirtilen türde bir alt öğe arar.
// Get the body section of the active document. var body = DocumentApp.getActiveDocument().getBody(); // Define the search parameters. var searchType = DocumentApp.ElementType.PARAGRAPH; var searchHeading = DocumentApp.ParagraphHeading.HEADING1; var searchResult = null; // Search until the paragraph is found. while (searchResult = body.findElement(searchType, searchResult)) { var par = searchResult.getElement().asParagraph(); if (par.getHeading() == searchHeading) { // Found one, update and stop. par.setText('This is the first header.'); return; } }
Parametreler
Ad | Type | Açıklama |
---|---|---|
elementType | ElementType | aranacak öğe türü |
from | RangeElement | arama yapılacak arama sonucu |
Return
RangeElement
- Arama öğesinin bir sonraki konumunu belirten arama sonucu
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findText(searchPattern)
Normal ifadeler kullanarak öğ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 metin bloğuyla bağımsız olarak eşleştirilir.
Parametreler
Ad | Type | Açıklama |
---|---|---|
searchPattern | String | aranacak kalıp |
Return
RangeElement
- Arama metninin konumunu belirten bir arama sonucu; eşleşme yoksa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findText(searchPattern, from)
Belirli bir arama sonucundan başlayarak, öğenin içeriğinde belirtilen metin kalıbını 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 metin bloğuyla bağımsız olarak eşleştirilir.
Parametreler
Ad | Type | Açıklama |
---|---|---|
searchPattern | String | aranacak kalıp |
from | RangeElement | arama yapılacak arama sonucu |
Return
RangeElement
- Arama metninin bir sonraki konumunu belirten arama sonucu; eşleşme yoksa null
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getAlignment()
HorizontalAlignment
değerini alır.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('abc123456'); // Gets the document body. const body = doc.getBody(); // Gets the first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Sets the horizontal alignment to left for the first paragraph. paragraph.setAlignment(DocumentApp.HorizontalAlignment.LEFT); // Gets the horizontal alignment of the first paragraph and logs it to the console. console.log(paragraph.getAlignment().toString());
Return
HorizontalAlignment
- Hizalama.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getAttributes()
Öğenin özelliklerini alır.
Sonuç olarak, her bir mülk adı DocumentApp.Attribute
enum öğesindeki bir öğeye karşılık gelen geçerli her öğe özelliği için bir özellik içeren bir nesne olur.
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ı, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getChild(childIndex)
Belirtilen alt dizindeki alt öğeyi alır.
// Get the body section of the active document. var body = DocumentApp.getActiveDocument().getBody(); // Obtain the first element in the document. var firstChild = body.getChild(0); // If it's a paragraph, set its contents. if (firstChild.getType() == DocumentApp.ElementType.PARAGRAPH) { firstChild.asParagraph().setText("This is the first paragraph."); }
Parametreler
Ad | Type | Açıklama |
---|---|---|
childIndex | Integer | alınacak alt öğenin dizini |
Return
Element
- belirtilen dizindeki alt öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getChildIndex(child)
Belirtilen alt öğenin alt dizinini alır.
Parametreler
Ad | Type | Açıklama |
---|---|---|
child | Element | dizini alınacak alt öğe |
Return
Integer
- alt dizin
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getHeading()
ParagraphHeading
değerini alır.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('abc123456'); // Gets the document body. const body = doc.getBody(); // Adds a paragraph to the body. const paragraph = body.appendParagraph('Title heading'); // Sets the paragraph heading style to 'Title.' paragraph.setHeading(DocumentApp.ParagraphHeading.TITLE); // Gets the heading style and logs it to the console. console.log(paragraph.getHeading().toString());
Return
ParagraphHeading
- Başlık.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getIndentEnd()
Uç girintiyi noktalar halinde alır.
Return
Number
- uç girintisi, nokta cinsinden
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getIndentFirstLine()
İlk satır girintisini noktalar halinde alır.
Return
Number
- nokta cinsinden ilk satır girintisi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getIndentStart()
Başlangıç girintisini alır.
Return
Number
- başlangıç girintisi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getLineSpacing()
Satır aralığını noktalar halinde alır.
Return
Number
- nokta cinsinden satır aralığı
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getLinkUrl()
Bağlantı URL'sini alır.
Return
String
: Bağlantı URL'si veya öğe, bu özellik için birden fazla değer içeriyorsa boş
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
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 olur ve geçerli öğeyi izler.
Return
Element
- Sonraki kardeş öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getNumChildren()
Alt öğelerin sayısını alır.
// Get the body section of the active document. var body = DocumentApp.getActiveDocument().getBody(); // Log the number of elements in the document. Logger.log("There are " + body.getNumChildren() + " elements in the document body.");
Return
Integer
- çocuk sayısı
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getParent()
Öğenin üst öğesini alır.
Üst öğe, geçerli öğeyi içerir.
Return
ContainerElement
: Üst öğedir.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getPositionedImage(id)
Resmin kimliğine göre bir PositionedImage
alır.
Parametreler
Ad | Type | Açıklama |
---|---|---|
id | String | resim kimliği |
Return
PositionedImage
- konumlandırılmış resim
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getPositionedImages()
Tüm PositionedImage
paragraflarını paragrafa sabitler.
Return
PositionedImage[]
- konumlandırılmış resimlerin listesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
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 öğenin önünde.
Return
Element
- Önceki kardeş öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getSpacingAfter()
Öğeden sonraki boşluğu noktalar halinde alır.
Return
Number
- Öğeden sonra boşluk
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getSpacingBefore()
Öğeden önceki boşluğu noktalar halinde alır.
Return
Number
- Öğeden önceki boşluk (nokta cinsinden)
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
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
- Metin dizesi olarak öğenin içeriği
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getTextAlignment()
Metnin 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 hizalaması hiç ayarlanmamışsanull
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getType()
Öğenin ElementType
özelliğini alır.
Belirli bir öğenin tam türünü belirlemek için getType()
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ı, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertHorizontalRule(childIndex)
Belirtilen dizinde bir HorizontalRule
oluşturur ve ekler.
Parametreler
Ad | Type | Açıklama |
---|---|---|
childIndex | Integer | öğenin ekleneceği dizin |
Return
HorizontalRule
- Yeni yatay kural öğesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertInlineImage(childIndex, image)
Belirtilen dizinde yeni bir InlineImage
oluşturur ve belirtilen dizine ekler.
Parametreler
Ad | Type | Açıklama |
---|---|---|
childIndex | Integer | öğenin ekleneceği dizin |
image | BlobSource | resim verileri |
Return
InlineImage
- eklenen satır içi resim öğesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertInlineImage(childIndex, image)
Belirtilen InlineImage
öğesini, belirtilen dizine ekler.
Parametreler
Ad | Type | Açıklama |
---|---|---|
childIndex | Integer | öğenin ekleneceği dizin |
image | InlineImage | resim verileri |
Return
InlineImage
- eklenen satır içi resim öğesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertPageBreak(childIndex)
Belirtilen dizinde yeni bir PageBreak
oluşturur ve ekler.
Not: PageBreaks
, TableCells
içinde bulunamaz.
Geçerli öğe bir tablo hücresinde yer alıyorsa bir istisna atılır.
Parametreler
Ad | Type | Açıklama |
---|---|---|
childIndex | Integer | öğenin ekleneceği dizin |
Return
PageBreak
- yeni sayfa sonu öğesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertPageBreak(childIndex, pageBreak)
Belirtilen PageBreak
öğesini, belirtilen dizine ekler.
Not: PageBreaks
, TableCells
içinde bulunamaz.
Geçerli öğe bir tablo hücresinde yer alıyorsa bir istisna atılır.
Parametreler
Ad | Type | Açıklama |
---|---|---|
childIndex | Integer | öğenin ekleneceği dizin |
pageBreak | PageBreak | p[age break at insert to |
Return
PageBreak
- eklenen sayfa sonu öğesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertText(childIndex, text)
Belirtilen dizinde yeni bir metin öğesi oluşturur ve ekler.
Parametreler
Ad | Type | Açıklama |
---|---|---|
childIndex | Integer | öğenin ekleneceği dizin |
text | String | metin içeriklerini |
Return
Text
- yeni metin öğesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
insertText(childIndex, text)
Belirtilen Text
öğesini, belirtilen dizin içeriğini belirtilen metin içerikleriyle ekler.
Parametreler
Ad | Type | Açıklama |
---|---|---|
childIndex | Integer | öğenin ekleneceği dizin |
text | Text | metin öğesi eklenir |
Return
Text
- ekli metin öğesi
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isAtDocumentEnd()
Öğenin, Document
öğesinin sonunda olup olmadığını belirler.
Return
Boolean
: Öğenin belgenin sonunda olup olmadığı.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isLeftToRight()
Soldan sağa ayarını alır.
Return
Boolean
— soldan sağa ayar
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
merge()
Öğeyi, aynı türde önceki kardeş öğeyle birleştirir.
Yalnızca aynı ElementType
öğeleri birleştirilebilir. Geçerli öğede bulunan alt öğeler önceki kardeş öğesine taşınır.
Geçerli öğe dokümandan kaldırılır.
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
Paragraph
- Birleştirilmiş öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
removeChild(child)
Belirtilen alt öğeyi kaldırır.
Parametreler
Ad | Type | Açıklama |
---|---|---|
child | Element | kaldırılacak alt öğe |
Return
Paragraph
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
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
Paragraph
: Kaldırılan öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
removePositionedImage(id)
Resim kimliğine göre bir PositionedImage
kaldırır.
Parametreler
Ad | Type | Açıklama |
---|---|---|
id | String | resim kimliği |
Return
Boolean
: Belirtilen resmin kaldırılıp kaldırılmadığı
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
replaceText(searchPattern, replacement)
Düzenli ifadeler kullanarak belirli bir metin kalıbının tüm tekrarlarını belirli bir değiştirme dizesiyle değiştirir.
Arama kalıbı, JavaScript normal ifade nesnesi olarak değil dize olarak aktarılır. Bu nedenle, kalıptaki tüm ters eğik çizgileri kod dışına almanız gerekir.
Bu yöntemle, Google'ın desteklenen söz dizimini sınırlayan RE2 normal ifade kitaplığı kullanılır.
Sağlanan normal ifade kalıbı, geçerli öğede yer alan her 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 | Type | Açıklama |
---|---|---|
searchPattern | String | aranacak normal ifade kalıbı |
replacement | String | yerine geçecek metin |
Return
Element
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setAlignment(alignment)
HorizontalAlignment
özelliğini ayarlar.
Parametreler
Ad | Type | Açıklama |
---|---|---|
alignment | HorizontalAlignment | yatay hizalama |
Return
Paragraph
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setAttributes(attributes)
Öğenin özelliklerini ayarlar.
Belirtilen özellikler parametresi, her bir özellik adının DocumentApp.Attribute
numaralandırmasındaki bir öğe ve her bir ö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 | Type | Açıklama |
---|---|---|
attributes | Object | Öğenin özellikleri. |
Return
Paragraph
: Geçerli öğe.
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setHeading(heading)
ParagraphHeading
özelliğini ayarlar.
Parametreler
Ad | Type | Açıklama |
---|---|---|
heading | ParagraphHeading | başlık |
Return
Paragraph
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setIndentEnd(indentEnd)
Bitiş girintisini noktalar halinde ayarlar.
Parametreler
Ad | Type | Açıklama |
---|---|---|
indentEnd | Number | punto cinsinden bitiş girintisi |
Return
Paragraph
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setIndentFirstLine(indentFirstLine)
İlk satır girintisini noktalar halinde ayarlar.
Parametreler
Ad | Type | Açıklama |
---|---|---|
indentFirstLine | Number | nokta cinsinden ilk satır girintisi |
Return
Paragraph
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setIndentStart(indentStart)
Başlangıç girintisini noktalar halinde ayarlar.
Parametreler
Ad | Type | Açıklama |
---|---|---|
indentStart | Number | başlangıç girintisi, punto cinsinden |
Return
Paragraph
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setLeftToRight(leftToRight)
Soldan sağa ayarını belirler.
Parametreler
Ad | Type | Açıklama |
---|---|---|
leftToRight | Boolean | soldan sağa ayar |
Return
Paragraph
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setLineSpacing(multiplier)
Satır aralığını, aralık olarak kullanılacak satır sayısını belirten bir miktar olarak ayarlar.
Parametreler
Ad | Type | Açıklama |
---|---|---|
multiplier | Number | satır sayısı |
Return
Paragraph
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setLinkUrl(url)
Bağlantı URL'sini ayarlar.
Parametreler
Ad | Type | Açıklama |
---|---|---|
url | String | bağlantı URL'si |
Return
Paragraph
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setSpacingAfter(spacingAfter)
Öğeden sonraki boşluğu noktalar halinde ayarlar.
Parametreler
Ad | Type | Açıklama |
---|---|---|
spacingAfter | Number | öğenin ardından boşlukla nokta cinsinden |
Return
Paragraph
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setSpacingBefore(spacingBefore)
Öğeden önceki boşluğu noktalar halinde ayarlar.
Parametreler
Ad | Type | Açıklama |
---|---|---|
spacingBefore | Number | öğenin önündeki boşluk |
Return
Paragraph
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setText(text)
Paragrafın içeriğini metin olarak ayarlar.
Not: Mevcut içerikler temizlenir.
Parametreler
Ad | Type | Açıklama |
---|---|---|
text | String | yeni metin içerikleri |
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setTextAlignment(textAlignment)
Metin hizalamasını ayarlar. Kullanılabilir hizalama türleri 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 | Type | Açıklama |
---|---|---|
textAlignment | TextAlignment | uygulanacak metin hizalamasının türü |
Return
Paragraph
- mevcut öğe
Yetkilendirme
Bu yöntemi kullanan komut dosyaları, aşağıdaki kapsamlardan en az biriyle yetkilendirme gerektirir:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents