Class ContainerElement

ContainerElement

एक सामान्य एलिमेंट, जिसमें अन्य एलिमेंट शामिल हो सकते हैं. वे सभी एलिमेंट जिनमें चाइल्ड एलिमेंट हो सकते हैं, जैसे कि Paragraph, ContainerElement से इनहेरिट किया जाता है.

तरीके

तरीकारिटर्न टाइपसंक्षिप्त विवरण
asBody()Bodyमौजूदा एलिमेंट को Body के तौर पर दिखाता है.
asEquation()Equationमौजूदा एलिमेंट को Equation के तौर पर दिखाता है.
asFooterSection()FooterSectionमौजूदा एलिमेंट को FooterSection के तौर पर दिखाता है.
asFootnoteSection()FootnoteSectionमौजूदा एलिमेंट को FootnoteSection के तौर पर दिखाता है.
asHeaderSection()HeaderSectionमौजूदा एलिमेंट को HeaderSection के तौर पर दिखाता है.
asListItem()ListItemमौजूदा एलिमेंट को ListItem के तौर पर दिखाता है.
asParagraph()Paragraphमौजूदा एलिमेंट को Paragraph के तौर पर दिखाता है.
asTable()Tableमौजूदा एलिमेंट को Table के तौर पर दिखाता है.
asTableCell()TableCellमौजूदा एलिमेंट को TableCell के तौर पर दिखाता है.
asTableOfContents()TableOfContentsमौजूदा एलिमेंट को TableOfContents के तौर पर दिखाता है.
asTableRow()TableRowमौजूदा एलिमेंट को TableRow के तौर पर दिखाता है.
clear()ContainerElementएलिमेंट के कॉन्टेंट को हटाता है.
copy()ContainerElementमौजूदा एलिमेंट की अलग की गई, डीप कॉपी दिखाता है.
editAsText()Textबदलाव करने के लिए, मौजूदा एलिमेंट का Text वर्शन हासिल करता है.
findElement(elementType)RangeElementबताए गए टाइप के डिसेंडेंट के लिए एलिमेंट की सामग्री खोजता है.
findElement(elementType, from)RangeElementचुने गए टाइप के डिसेंडेंट के लिए एलिमेंट की सामग्री खोजता है, जिसकी शुरुआत RangeElement बताया गया.
findText(searchPattern)RangeElementरेगुलर एक्सप्रेशन का इस्तेमाल करके, तय किए गए टेक्स्ट पैटर्न के एलिमेंट के कॉन्टेंट की खोज करता है.
findText(searchPattern, from)RangeElementदिए गए टेक्स्ट पैटर्न के लिए, एलिमेंट के कॉन्टेंट की खोज करता है. इसकी शुरुआत, दिए गए टेक्स्ट से होती है खोज के नतीजे.
getAttributes()Objectएलिमेंट के एट्रिब्यूट हासिल करता है.
getChild(childIndex)Elementबताए गए चाइल्ड इंडेक्स में चाइल्ड एलीमेंट को हासिल करता है.
getChildIndex(child)Integerबताए गए चाइल्ड एलिमेंट के लिए चाइल्ड इंडेक्स फिर से लाता है.
getLinkUrl()Stringलिंक के यूआरएल को वापस लाता है.
getNextSibling()Elementयह एलिमेंट का अगला सिबलिंग एलिमेंट हासिल करता है.
getNumChildren()Integerबच्चों की संख्या की जानकारी देता है.
getParent()ContainerElementएलिमेंट के पैरंट एलिमेंट को हासिल करता है.
getPreviousSibling()Elementयह एलिमेंट के पिछले सिबलिंग एलिमेंट को हासिल करता है.
getText()Stringएलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर वापस लाता है.
getTextAlignment()TextAlignmentइससे टेक्स्ट अलाइनमेंट की सुविधा मिलती है.
getType()ElementTypeएलिमेंट के ElementType को हासिल करता है.
isAtDocumentEnd()Booleanयह तय करता है कि एलिमेंट, Document के आखिर में है या नहीं.
merge()ContainerElementयह एलिमेंट को एक ही टाइप के पिछले सिबलिंग के साथ मर्ज करता है.
removeFromParent()ContainerElementएलिमेंट को इसकी पैरंट जगह से हटाता है.
replaceText(searchPattern, replacement)Elementसामान्य का उपयोग करके, दिए गए बदले हुए स्ट्रिंग से दिए गए लेख पैटर्न की सभी आवृत्तियां बदलता है एक्सप्रेशन के बारे में भी बताया गया है.
setAttributes(attributes)ContainerElementएलिमेंट के एट्रिब्यूट सेट करता है.
setLinkUrl(url)ContainerElementलिंक का यूआरएल सेट करता है.
setTextAlignment(textAlignment)ContainerElementटेक्स्ट अलाइनमेंट सेट करता है.

विस्तृत दस्तावेज़

asBody()

मौजूदा एलिमेंट को Body के तौर पर दिखाता है.

जब भी दिया गया एलिमेंट किसी खास ऑब्जेक्ट के बारे में हो, तो उसे अपने-आप पूरा करने के लिए, इस तरीके का इस्तेमाल करें टाइप करें.

वापसी का टिकट

Body — मौजूदा एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

asEquation()

मौजूदा एलिमेंट को Equation के तौर पर दिखाता है.

जब भी दिया गया एलिमेंट किसी खास ऑब्जेक्ट के बारे में हो, तो उसे अपने-आप पूरा करने के लिए, इस तरीके का इस्तेमाल करें टाइप करें.

वापसी का टिकट

Equation — मौजूदा एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

asFooterSection()

मौजूदा एलिमेंट को FooterSection के तौर पर दिखाता है.

जब भी दिया गया एलिमेंट किसी खास ऑब्जेक्ट के बारे में हो, तो उसे अपने-आप पूरा करने के लिए, इस तरीके का इस्तेमाल करें टाइप करें.

वापसी का टिकट

FooterSection — मौजूदा एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

asFootnoteSection()

मौजूदा एलिमेंट को FootnoteSection के तौर पर दिखाता है.

जब भी दिया गया एलिमेंट किसी खास ऑब्जेक्ट के बारे में हो, तो उसे अपने-आप पूरा करने के लिए, इस तरीके का इस्तेमाल करें टाइप करें.

वापसी का टिकट

FootnoteSection — मौजूदा एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

asHeaderSection()

मौजूदा एलिमेंट को HeaderSection के तौर पर दिखाता है.

जब भी दिया गया एलिमेंट किसी खास ऑब्जेक्ट के बारे में हो, तो उसे अपने-आप पूरा करने के लिए, इस तरीके का इस्तेमाल करें टाइप करें.

वापसी का टिकट

HeaderSection — मौजूदा एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

asListItem()

मौजूदा एलिमेंट को ListItem के तौर पर दिखाता है.

जब भी दिया गया एलिमेंट किसी खास ऑब्जेक्ट के बारे में हो, तो उसे अपने-आप पूरा करने के लिए, इस तरीके का इस्तेमाल करें टाइप करें.

वापसी का टिकट

ListItem — मौजूदा एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

asParagraph()

मौजूदा एलिमेंट को Paragraph के तौर पर दिखाता है.

जब भी दिया गया एलिमेंट किसी खास ऑब्जेक्ट के बारे में हो, तो उसे अपने-आप पूरा करने के लिए, इस तरीके का इस्तेमाल करें टाइप करें.

वापसी का टिकट

Paragraph — मौजूदा एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

asTable()

मौजूदा एलिमेंट को Table के तौर पर दिखाता है.

जब भी दिया गया एलिमेंट किसी खास ऑब्जेक्ट के बारे में हो, तो उसे अपने-आप पूरा करने के लिए, इस तरीके का इस्तेमाल करें टाइप करें.

वापसी का टिकट

Table — मौजूदा एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

asTableCell()

मौजूदा एलिमेंट को TableCell के तौर पर दिखाता है.

जब भी दिया गया एलिमेंट किसी खास ऑब्जेक्ट के बारे में हो, तो उसे अपने-आप पूरा करने के लिए, इस तरीके का इस्तेमाल करें टाइप करें.

वापसी का टिकट

TableCell — मौजूदा एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

asTableOfContents()

मौजूदा एलिमेंट को TableOfContents के तौर पर दिखाता है.

जब भी दिया गया एलिमेंट किसी खास ऑब्जेक्ट के बारे में हो, तो उसे अपने-आप पूरा करने के लिए, इस तरीके का इस्तेमाल करें टाइप करें.

वापसी का टिकट

TableOfContents — मौजूदा एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

asTableRow()

मौजूदा एलिमेंट को TableRow के तौर पर दिखाता है.

जब भी दिया गया एलिमेंट किसी खास ऑब्जेक्ट के बारे में हो, तो उसे अपने-आप पूरा करने के लिए, इस तरीके का इस्तेमाल करें टाइप करें.

वापसी का टिकट

TableRow — मौजूदा एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

clear()

एलिमेंट के कॉन्टेंट को हटाता है.

वापसी का टिकट

ContainerElement — मौजूदा एलिमेंट.


copy()

मौजूदा एलिमेंट की अलग की गई, डीप कॉपी दिखाता है.

एलिमेंट में मौजूद सभी चाइल्ड एलिमेंट भी कॉपी कर लिए जाते हैं. नए एलिमेंट में यह मौजूद नहीं है पैरंट.

वापसी का टिकट

ContainerElement — नई कॉपी.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

editAsText()

बदलाव करने के लिए, मौजूदा एलिमेंट का Text वर्शन हासिल करता है.

एलिमेंट के कॉन्टेंट में रिच टेक्स्ट के तौर पर बदलाव करने के लिए, editAsText का इस्तेमाल करें. editAsText मोड बिना टेक्स्ट वाले एलिमेंट को अनदेखा कर देता है (जैसे कि InlineImage और HorizontalRule).

मिटाई गई टेक्स्ट रेंज में पूरी तरह से मौजूद चाइल्ड एलिमेंट, एलिमेंट से हटा दिए जाते हैं.

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

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

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

वापसी का टिकट

Text — मौजूदा एलिमेंट का टेक्स्ट वर्शन


findElement(elementType)

बताए गए टाइप के डिसेंडेंट के लिए एलिमेंट की सामग्री खोजता है.

पैरामीटर

नामटाइपब्यौरा
elementTypeElementTypeखोजने के लिए एलिमेंट का टाइप.

वापसी का टिकट

RangeElement — खोज के नतीजे में, खोज एलिमेंट की पोज़िशन के बारे में बताया जाता है.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

findElement(elementType, from)

चुने गए टाइप के डिसेंडेंट के लिए एलिमेंट की सामग्री खोजता है, जिसकी शुरुआत RangeElement बताया गया.

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().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;
  }
}

पैरामीटर

नामटाइपब्यौरा
elementTypeElementTypeखोजने के लिए एलिमेंट का टाइप.
fromRangeElementवह खोज नतीजा जिससे खोजना है.

वापसी का टिकट

RangeElement — खोज का नतीजा, जो खोज एलिमेंट की अगली पोज़िशन दिखाता है.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

findText(searchPattern)

रेगुलर एक्सप्रेशन का इस्तेमाल करके, तय किए गए टेक्स्ट पैटर्न के एलिमेंट के कॉन्टेंट की खोज करता है.

JavaScript रेगुलर एक्सप्रेशन सुविधाओं का एक सबसेट पूरी तरह से काम नहीं करता, जैसे कि कैप्चर ग्रुप और मोड मॉडिफ़ायर.

दिया गया रेगुलर एक्सप्रेशन पैटर्न, हर टेक्स्ट ब्लॉक से अलग से मैच किया जाता है जो मौजूदा एलिमेंट में शामिल हों.

पैरामीटर

नामटाइपब्यौरा
searchPatternStringखोजने के लिए पैटर्न

वापसी का टिकट

RangeElement — खोज के नतीजे से यह पता चलता है कि खोज के टेक्स्ट की जगह क्या है या अगर कोई टेक्स्ट मौजूद नहीं है, तो यह जानकारी शून्य होती है मिलान

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

findText(searchPattern, from)

दिए गए टेक्स्ट पैटर्न के लिए, एलिमेंट के कॉन्टेंट की खोज करता है. इसकी शुरुआत, दिए गए टेक्स्ट से होती है खोज के नतीजे.

JavaScript रेगुलर एक्सप्रेशन सुविधाओं का एक सबसेट पूरी तरह से काम नहीं करता, जैसे कि कैप्चर ग्रुप और मोड मॉडिफ़ायर.

दिया गया रेगुलर एक्सप्रेशन पैटर्न, हर टेक्स्ट ब्लॉक से अलग से मैच किया जाता है जो मौजूदा एलिमेंट में शामिल हों.

पैरामीटर

नामटाइपब्यौरा
searchPatternStringखोजने के लिए पैटर्न
fromRangeElementवह खोज नतीजा जिससे खोजना है

वापसी का टिकट

RangeElement — ऐसा खोज नतीजा, जो खोज के टेक्स्ट की अगली जगह दिखाता है या अगर कोई जगह नहीं है, तो यह शून्य होता है मिलान

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

getAttributes()

एलिमेंट के एट्रिब्यूट हासिल करता है.

नतीजा एक ऐसा ऑब्जेक्ट होता है जिसमें हर एक मान्य एलिमेंट एट्रिब्यूट के लिए एक प्रॉपर्टी होती है, जहां हर प्रॉपर्टी का नाम, DocumentApp.Attribute की गिनती में मौजूद किसी आइटम से मेल खाता है.

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

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

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

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

वापसी का टिकट

Object — एलिमेंट के एट्रिब्यूट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

getChild(childIndex)

बताए गए चाइल्ड इंडेक्स में चाइल्ड एलीमेंट को हासिल करता है.

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

// Obtain the first element in the tab.
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.");
}

पैरामीटर

नामटाइपब्यौरा
childIndexIntegerफिर से पाने के लिए चाइल्ड एलिमेंट का इंडेक्स.

वापसी का टिकट

Element — बताए गए इंडेक्स में चाइल्ड एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

getChildIndex(child)

बताए गए चाइल्ड एलिमेंट के लिए चाइल्ड इंडेक्स फिर से लाता है.

पैरामीटर

नामटाइपब्यौरा
childElementवह चाइल्ड एलिमेंट जिसके लिए इंडेक्स को फिर से हासिल करना है.

वापसी का टिकट

Integer — चाइल्ड इंडेक्स.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

getLinkUrl()

लिंक के यूआरएल को वापस लाता है.

वापसी का टिकट

String — अगर एलिमेंट में इस एट्रिब्यूट के लिए एक से ज़्यादा वैल्यू हैं, तो लिंक का यूआरएल या शून्य

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

getNextSibling()

यह एलिमेंट का अगला सिबलिंग एलिमेंट हासिल करता है.

अगले सिबलिंग का वही पैरंट है और वे मौजूदा एलिमेंट को फ़ॉलो करते हैं.

वापसी का टिकट

Element — अगला सिबलिंग एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

getNumChildren()

बच्चों की संख्या की जानकारी देता है.

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

// Log the number of elements in the tab.
Logger.log("There are " + body.getNumChildren() +
    " elements in the tab's body.");

वापसी का टिकट

Integer — बच्चों की संख्या.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

getParent()

एलिमेंट के पैरंट एलिमेंट को हासिल करता है.

पैरंट एलिमेंट में मौजूदा एलिमेंट शामिल है.

वापसी का टिकट

ContainerElement — पैरंट एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

getPreviousSibling()

यह एलिमेंट के पिछले सिबलिंग एलिमेंट को हासिल करता है.

पिछले सिबलिंग का पैरंट ही है और मौजूदा एलिमेंट से पहले आता है.

वापसी का टिकट

Element — पिछला सिबलिंग एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

getText()

एलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर वापस लाता है.

वापसी का टिकट

String — टेक्स्ट स्ट्रिंग के रूप में एलिमेंट का कॉन्टेंट

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

getTextAlignment()

इससे टेक्स्ट अलाइनमेंट की सुविधा मिलती है. अलाइनमेंट के उपलब्ध टाइप DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT, और DocumentApp.TextAlignment.SUPERSCRIPT हैं.

वापसी का टिकट

TextAlignment — टेक्स्ट अलाइनमेंट का टाइप या अगर टेक्स्ट में एक से ज़्यादा तरह के टेक्स्ट शामिल हैं, तो null अलाइनमेंट या अगर टेक्स्ट अलाइनमेंट कभी सेट नहीं किया गया है

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

getType()

एलिमेंट के ElementType को हासिल करता है.

दिए गए एलिमेंट का सटीक टाइप तय करने के लिए, getType() का इस्तेमाल करें.

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

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

var firstChild = body.getChild(0);

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

वापसी का टिकट

ElementType — एलिमेंट का टाइप.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

isAtDocumentEnd()

यह तय करता है कि एलिमेंट, Document के आखिर में है या नहीं.

वापसी का टिकट

Boolean — टैब के आखिर में एलिमेंट है या नहीं.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

merge()

यह एलिमेंट को एक ही टाइप के पिछले सिबलिंग के साथ मर्ज करता है.

सिर्फ़ एक ही ElementType के एलिमेंट मर्ज किए जा सकते हैं. इसमें मौजूद कोई भी चाइल्ड एलिमेंट मौजूदा एलिमेंट को पिछले सिबलिंग एलिमेंट में ले जाया जाता है.

मौजूदा एलिमेंट को दस्तावेज़ से हटा दिया जाता है.

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

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

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

वापसी का टिकट

ContainerElement — मर्ज किया गया एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

removeFromParent()

एलिमेंट को इसकी पैरंट जगह से हटाता है.

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

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

वापसी का टिकट

ContainerElement — हटाया गया एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

replaceText(searchPattern, replacement)

सामान्य का उपयोग करके, दिए गए बदले हुए स्ट्रिंग से दिए गए लेख पैटर्न की सभी आवृत्तियां बदलता है एक्सप्रेशन के बारे में भी बताया गया है.

खोज पैटर्न को स्ट्रिंग के तौर पर पास किया जाता है, न कि JavaScript रेगुलर एक्सप्रेशन ऑब्जेक्ट के तौर पर. इसलिए, आपको पैटर्न में बैकस्लैश को एस्केप करना होगा.

इस तरीके में, Google के RE2 रेगुलर एक्सप्रेशन का इस्तेमाल किया जाता है एक्सप्रेशन लाइब्रेरी, जो इस्तेमाल किए जा सकने वाले सिंटैक्स को सीमित करती है.

दिया गया रेगुलर एक्सप्रेशन पैटर्न, हर टेक्स्ट ब्लॉक से अलग से मैच किया जाता है जो मौजूदा एलिमेंट में शामिल हों.

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

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

पैरामीटर

नामटाइपब्यौरा
searchPatternStringखोजने के लिए रेगुलर एक्सप्रेशन पैटर्न
replacementStringबदले जाने के लिए इस्तेमाल किया जाने वाला टेक्स्ट

वापसी का टिकट

Element — मौजूदा एलिमेंट

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

setAttributes(attributes)

एलिमेंट के एट्रिब्यूट सेट करता है.

बताया गया विशेषता पैरामीटर एक ऐसा ऑब्जेक्ट होना चाहिए, जिसमें हर प्रॉपर्टी का नाम एक आइटम हो DocumentApp.Attribute की गिनती और हर प्रॉपर्टी की वैल्यू, नई वैल्यू होगी लागू किया गया.

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

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

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

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

पैरामीटर

नामटाइपब्यौरा
attributesObjectएलिमेंट के एट्रिब्यूट.

वापसी का टिकट

ContainerElement — मौजूदा एलिमेंट.

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

setLinkUrl(url)

लिंक का यूआरएल सेट करता है.

पैरामीटर

नामटाइपब्यौरा
urlStringलिंक का यूआरएल

वापसी का टिकट

ContainerElement — मौजूदा एलिमेंट

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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

setTextAlignment(textAlignment)

टेक्स्ट अलाइनमेंट सेट करता है. अलाइनमेंट के उपलब्ध टाइप DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT, और DocumentApp.TextAlignment.SUPERSCRIPT हैं.

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

पैरामीटर

नामटाइपब्यौरा
textAlignmentTextAlignmentलागू किए जाने वाले लेख संरेखण का प्रकार

वापसी का टिकट

ContainerElement — मौजूदा एलिमेंट

अनुमति देना

इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, यहां दिए गए एक या एक से ज़्यादा स्कोप की अनुमति होनी चाहिए:

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