Class Paragraph

Paragraf

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öntemDönüş türüKısa açıklama
addPositionedImage(image)PositionedImageBelirtilen resim blobundan yeni bir PositionedImage oluşturur ve ekler.
appendHorizontalRule()HorizontalRuleYeni bir HorizontalRule oluşturur ve ekler.
appendInlineImage(image)InlineImageBelirtilen resim blobundan yeni bir InlineImage oluşturur ve ekler.
appendInlineImage(image)InlineImageBelirtilen InlineImage eklenir.
appendPageBreak()PageBreakYeni bir PageBreak oluşturur ve ekler.
appendPageBreak(pageBreak)PageBreakBelirtilen PageBreak eklenir.
appendText(text)TextBelirtilen içerikle yeni bir Text öğesi oluşturur ve ekler.
appendText(text)TextBelirtilen Text öğesini ekler.
clear()ParagraphÖğenin içeriğini temizler.
copy()ParagraphMevcut öğenin ayrılmış, derin bir kopyasını döndürür.
editAsText()TextDü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)RangeElementNormal ifadeler kullanarak öğenin içeriğini belirtilen metin kalıbı için arar.
findText(searchPattern, from)RangeElementBelirli bir arama sonucundan başlayarak, öğenin içeriğinde belirtilen metin kalıbını arar.
getAlignment()HorizontalAlignmentHorizontalAlignment değerini alır.
getAttributes()ObjectÖğenin özelliklerini alır.
getChild(childIndex)ElementBelirtilen alt dizindeki alt öğeyi alır.
getChildIndex(child)IntegerBelirtilen alt öğenin alt dizinini alır.
getHeading()ParagraphHeadingParagraphHeading değerini alır.
getIndentEnd()NumberUç girintiyi noktalar halinde alır.
getIndentFirstLine()Numberİlk satır girintisini noktalar halinde alır.
getIndentStart()NumberBaşlangıç girintisini alır.
getLineSpacing()NumberSatır aralığını noktalar halinde alır.
getLinkUrl()StringBağlantı URL'sini alır.
getNextSibling()ElementÖğenin sonraki kardeş öğesini alır.
getNumChildren()IntegerAlt öğelerin sayısını alır.
getParent()ContainerElementÖğenin üst öğesini alır.
getPositionedImage(id)PositionedImageResmin 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()TextAlignmentMetnin hizalamasını alır.
getType()ElementTypeÖğenin ElementType özelliğini alır.
insertHorizontalRule(childIndex)HorizontalRuleBelirtilen dizinde bir HorizontalRule oluşturur ve ekler.
insertInlineImage(childIndex, image)InlineImageBelirtilen dizinde yeni bir InlineImage oluşturur ve belirtilen dizine ekler.
insertInlineImage(childIndex, image)InlineImageBelirtilen InlineImage öğesini, belirtilen dizine ekler.
insertPageBreak(childIndex)PageBreakBelirtilen dizinde yeni bir PageBreak oluşturur ve ekler.
insertPageBreak(childIndex, pageBreak)PageBreakBelirtilen PageBreak öğesini, belirtilen dizine ekler.
insertText(childIndex, text)TextBelirtilen dizinde yeni bir metin öğesi oluşturur ve ekler.
insertText(childIndex, text)TextBelirtilen Text öğesini, belirtilen dizin içeriğini belirtilen metin içerikleriyle ekler.
isAtDocumentEnd()BooleanÖğenin, Document öğesinin sonunda olup olmadığını belirler.
isLeftToRight()BooleanSoldan sağa ayarını alır.
merge()ParagraphÖğeyi, aynı türde önceki kardeş öğeyle birleştirir.
removeChild(child)ParagraphBelirtilen alt öğeyi kaldırır.
removeFromParent()ParagraphÖğeyi üst öğesinden kaldırır.
removePositionedImage(id)BooleanResim kimliğine göre bir PositionedImage kaldırır.
replaceText(searchPattern, replacement)ElementDü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)ParagraphHorizontalAlignment özelliğini ayarlar.
setAttributes(attributes)ParagraphÖğenin özelliklerini ayarlar.
setHeading(heading)ParagraphParagraphHeading özelliğini ayarlar.
setIndentEnd(indentEnd)ParagraphBitiş girintisini noktalar halinde ayarlar.
setIndentFirstLine(indentFirstLine)Paragraphİlk satır girintisini noktalar halinde ayarlar.
setIndentStart(indentStart)ParagraphBaşlangıç girintisini noktalar halinde ayarlar.
setLeftToRight(leftToRight)ParagraphSoldan sağa ayarını belirler.
setLineSpacing(multiplier)ParagraphSatır aralığını, aralık olarak kullanılacak satır sayısını belirten bir miktar olarak ayarlar.
setLinkUrl(url)ParagraphBağ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)voidParagrafın içeriğini metin olarak ayarlar.
setTextAlignment(textAlignment)ParagraphMetin 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

AdTypeAçıklama
imageBlobSourceResim 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

AdTypeAçıklama
imageBlobSourceResim 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

AdTypeAçıklama
imageInlineImageResim 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

AdTypeAçıklama
pageBreakPageBreakEklenecek 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

AdTypeAçıklama
textStringMetin 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

AdTypeAçıklama
textTextEklenecek 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()

Öğenin içeriğini temizler.

Return

Paragraph - mevcut öğe


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

AdTypeAçıklama
elementTypeElementTypearanacak öğ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

AdTypeAçıklama
elementTypeElementTypearanacak öğe türü
fromRangeElementarama 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

AdTypeAçıklama
searchPatternStringaranacak 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

AdTypeAçıklama
searchPatternStringaranacak kalıp
fromRangeElementarama 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

AdTypeAçıklama
childIndexIntegeralı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

AdTypeAçıklama
childElementdizini 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

AdTypeAçıklama
idStringresim 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

AdTypeAçıklama
childIndexIntegeröğ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

AdTypeAçıklama
childIndexIntegeröğenin ekleneceği dizin
imageBlobSourceresim 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

AdTypeAçıklama
childIndexIntegeröğenin ekleneceği dizin
imageInlineImageresim 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

AdTypeAçıklama
childIndexIntegeröğ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

AdTypeAçıklama
childIndexIntegeröğenin ekleneceği dizin
pageBreakPageBreakp[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

AdTypeAçıklama
childIndexIntegeröğenin ekleneceği dizin
textStringmetin 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

AdTypeAçıklama
childIndexIntegeröğenin ekleneceği dizin
textTextmetin öğ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

AdTypeAçıklama
childElementkaldı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

AdTypeAçıklama
idStringresim 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

AdTypeAçıklama
searchPatternStringaranacak normal ifade kalıbı
replacementStringyerine 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

AdTypeAçıklama
alignmentHorizontalAlignmentyatay 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

AdTypeAçıklama
attributesObjectÖğ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

AdTypeAçıklama
headingParagraphHeadingbaş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

AdTypeAçıklama
indentEndNumberpunto 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

AdTypeAçıklama
indentFirstLineNumbernokta 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

AdTypeAçıklama
indentStartNumberbaş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

AdTypeAçıklama
leftToRightBooleansoldan 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

AdTypeAçıklama
multiplierNumbersatı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

AdTypeAçıklama
urlStringbağ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

AdTypeAçıklama
spacingAfterNumberöğ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

AdTypeAçıklama
spacingBeforeNumberöğ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

AdTypeAçıklama
textStringyeni 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

AdTypeAçıklama
textAlignmentTextAlignmentuygulanacak 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