Class HeaderSection

HeaderSection

यह हेडर सेक्शन को दिखाने वाला एलिमेंट है. आम तौर पर, Document में ज़्यादा से ज़्यादा एक HeaderSection होता है. HeaderSection में ListItem, Paragraph, और Table एलिमेंट हो सकते हैं. दस्तावेज़ के स्ट्रक्चर के बारे में ज़्यादा जानने के लिए, Google Docs को एक्सटेंड करने से जुड़ी गाइड देखें.

तरीके

तरीकारिटर्न टाइपसंक्षिप्त विवरण
appendHorizontalRule()HorizontalRuleयह एक नया HorizontalRule बनाता है और उसे जोड़ता है.
appendImage(image)InlineImageयह फ़ंक्शन, दी गई इमेज के बड़े बाइनरी ऑब्जेक्ट (ब्लॉब) से नया InlineImage बनाता है और उसे जोड़ता है.
appendImage(image)InlineImageदिए गए InlineImage को जोड़ता है.
appendListItem(listItem)ListItemदिए गए ListItem को जोड़ता है.
appendListItem(text)ListItemयह फ़ंक्शन, तय किए गए टेक्स्ट कॉन्टेंट वाला नया ListItem बनाता है और उसे जोड़ता है.
appendParagraph(paragraph)Paragraphदिए गए Paragraph को जोड़ता है.
appendParagraph(text)Paragraphयह फ़ंक्शन, तय किए गए टेक्स्ट कॉन्टेंट वाला नया Paragraph बनाता है और उसे जोड़ता है.
appendTable()Tableयह एक नया Table बनाता है और उसे जोड़ता है.
appendTable(cells)Tableयह फ़ंक्शन, हर स्ट्रिंग वैल्यू के लिए एक TableCell बनाता है और उसे नए Table में जोड़ता है.
appendTable(table)Tableदिए गए Table को जोड़ता है.
clear()HeaderSectionइससे एलिमेंट का कॉन्टेंट मिट जाता है.
copy()HeaderSectionयह फ़ंक्शन, मौजूदा एलिमेंट की अलग की गई डीप कॉपी दिखाता है.
editAsText()Textबदलाव करने के लिए, मौजूदा एलिमेंट का Text वर्शन मिलता है.
findElement(elementType)RangeElement|nullयह फ़ंक्शन, एलिमेंट के कॉन्टेंट में, तय किए गए टाइप के डिसेंडेंट को खोजता है.
findElement(elementType, from)RangeElement|nullयह फ़ंक्शन, एलिमेंट के कॉन्टेंट में दिए गए टाइप के डिसेंडेंट को खोजता है. यह खोज, दिए गए RangeElement से शुरू होती है.
findText(searchPattern)RangeElement|nullरेगुलर एक्सप्रेशन का इस्तेमाल करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है.
findText(searchPattern, from)RangeElement|nullयह फ़ंक्शन, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है. यह खोज, दिए गए खोज नतीजे से शुरू होती है.
getAttributes()Objectयह एलिमेंट के एट्रिब्यूट वापस लाता है.
getChild(childIndex)Elementयह फ़ंक्शन, दिए गए चाइल्ड इंडेक्स पर मौजूद चाइल्ड एलिमेंट को वापस लाता है.
getChildIndex(child)Integerयह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट के लिए चाइल्ड इंडेक्स को वापस लाता है.
getImages()InlineImage[]|nullइस सेक्शन में मौजूद सभी InlineImages को वापस लाता है.
getListItems()ListItem[]|nullइस सेक्शन में मौजूद सभी ListItems को वापस लाता है.
getNumChildren()Integerइससे बच्चों की संख्या मिलती है.
getParagraphs()Paragraph[]|nullयह सेक्शन में मौजूद सभी Paragraphs (इसमें ListItems भी शामिल है) को वापस लाता है.
getParent()ContainerElement|nullयह एलिमेंट के पैरंट एलिमेंट को वापस लाता है.
getTables()Table[]|nullइस सेक्शन में मौजूद सभी Tables को वापस लाता है.
getText()Stringयह फ़ंक्शन, एलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर वापस लाता है.
getTextAlignment()TextAlignment|nullटेक्स्ट अलाइनमेंट की जानकारी मिलती है.
getType()ElementTypeयह एलिमेंट के ElementType को वापस लाता है.
insertHorizontalRule(childIndex)HorizontalRuleयह तय किए गए इंडेक्स पर, नया HorizontalRule बनाता है और उसे डालता है.
insertImage(childIndex, image)InlineImageयह फ़ंक्शन, तय किए गए इंडेक्स पर, तय की गई इमेज के बड़े ऑब्जेक्ट से InlineImage बनाता है और उसे शामिल करता है.
insertImage(childIndex, image)InlineImageयह फ़ंक्शन, दिए गए इंडेक्स पर InlineImage को शामिल करता है.
insertListItem(childIndex, listItem)ListItemयह फ़ंक्शन, दिए गए इंडेक्स पर ListItem को शामिल करता है.
insertListItem(childIndex, text)ListItemयह तय किए गए इंडेक्स पर एक नया ListItem बनाता है और उसे डालता है. इसमें तय किया गया टेक्स्ट कॉन्टेंट होता है.
insertParagraph(childIndex, paragraph)Paragraphयह फ़ंक्शन, दिए गए इंडेक्स पर Paragraph को शामिल करता है.
insertParagraph(childIndex, text)Paragraphयह तय किए गए इंडेक्स पर एक नया Paragraph बनाता है और उसे डालता है. इसमें तय किया गया टेक्स्ट कॉन्टेंट होता है.
insertTable(childIndex)Tableयह तय किए गए इंडेक्स पर, नया Table बनाता है और उसे डालता है.
insertTable(childIndex, cells)Tableयह फ़ंक्शन, तय किए गए इंडेक्स पर, तय की गई सेल वाला नया Table बनाता है और उसे डालता है.
insertTable(childIndex, table)Tableयह फ़ंक्शन, दिए गए इंडेक्स पर Table को शामिल करता है.
removeChild(child)HeaderSectionयह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट को हटाता है.
removeFromParent()HeaderSection|nullइस फ़ंक्शन का इस्तेमाल करके, एलिमेंट को उसके पैरंट से हटाया जा सकता है.
replaceText(searchPattern, replacement)Elementरेगुलर एक्सप्रेशन का इस्तेमाल करके, दिए गए टेक्स्ट पैटर्न की सभी जगहों पर, दिए गए रिप्लेसमेंट स्ट्रिंग को बदलता है.
setAttributes(attributes)HeaderSectionयह एलिमेंट के एट्रिब्यूट सेट करता है.
setText(text)HeaderSectionइससे कॉन्टेंट को सामान्य टेक्स्ट के तौर पर सेट किया जाता है.
setTextAlignment(textAlignment)HeaderSectionइससे टेक्स्ट अलाइनमेंट सेट किया जाता है.

ज़्यादा जानकारी वाला दस्तावेज़

appendHorizontalRule()

यह एक नया HorizontalRule बनाता है और उसे जोड़ता है.

HorizontalRule को एक नए Paragraph में शामिल किया जाएगा.

वापसी का टिकट

HorizontalRule — नया हॉरिज़ॉन्टल रूल.

अनुमति देना

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

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

appendImage(image)

यह फ़ंक्शन, दी गई इमेज के बड़े बाइनरी ऑब्जेक्ट (ब्लॉब) से नया InlineImage बनाता है और उसे जोड़ता है.

इमेज को एक नए Paragraph में शामिल किया जाएगा.

पैरामीटर

नामटाइपब्यौरा
imageBlobSourceइमेज का डेटा.

वापसी का टिकट

InlineImage — जोड़ी गई इमेज.

अनुमति देना

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

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

appendImage(image)

दिए गए InlineImage को जोड़ता है.

InlineImage को एक नए Paragraph में शामिल किया जाएगा.

मौजूदा InlineImage की कॉपी जोड़ने के लिए, appendImage के इस वर्शन का इस्तेमाल करें.

पैरामीटर

नामटाइपब्यौरा
imageInlineImageइमेज का डेटा.

वापसी का टिकट

InlineImage — जोड़ी गई इमेज.

अनुमति देना

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

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

appendListItem(listItem)

दिए गए ListItem को जोड़ता है.

मौजूदा ListItem की कॉपी जोड़ने के लिए, appendListItem के इस वर्शन का इस्तेमाल करें.

पैरामीटर

नामटाइपब्यौरा
listItemListItemवह सूची आइटम जिसे जोड़ना है.

वापसी का टिकट

ListItem — जोड़ी गई सूची का आइटम.

अनुमति देना

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

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

appendListItem(text)

यह फ़ंक्शन, तय किए गए टेक्स्ट कॉन्टेंट वाला नया ListItem बनाता है और उसे जोड़ता है.

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

पैरामीटर

नामटाइपब्यौरा
textStringसूची के आइटम का टेक्स्ट कॉन्टेंट.

वापसी का टिकट

ListItem — सूची में जोड़ा गया नया आइटम.

अनुमति देना

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

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

appendParagraph(paragraph)

दिए गए Paragraph को जोड़ता है.

मौजूदा Paragraph की कॉपी जोड़ने के लिए, appendParagraph के इस वर्शन का इस्तेमाल करें.

पैरामीटर

नामटाइपब्यौरा
paragraphParagraphजोड़ा जाने वाला पैराग्राफ़.

वापसी का टिकट

Paragraph — जोड़ा गया पैराग्राफ़.

अनुमति देना

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

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

appendParagraph(text)

यह फ़ंक्शन, तय किए गए टेक्स्ट कॉन्टेंट वाला नया Paragraph बनाता है और उसे जोड़ता है.

पैरामीटर

नामटाइपब्यौरा
textStringपैराग्राफ़ का टेक्स्ट कॉन्टेंट.

वापसी का टिकट

Paragraph — नया पैराग्राफ़.

अनुमति देना

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

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

appendTable()

यह एक नया Table बनाता है और उसे जोड़ता है.

इस तरीके से, टेबल के बाद एक खाली पैराग्राफ़ भी जुड़ जाएगा. ऐसा इसलिए, क्योंकि Google Docs दस्तावेज़ों में टेबल के बाद कुछ न कुछ टेक्स्ट होना ज़रूरी है.

वापसी का टिकट

Table — नई टेबल.

अनुमति देना

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

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

appendTable(cells)

यह फ़ंक्शन, हर स्ट्रिंग वैल्यू के लिए एक TableCell बनाता है और उसे नए Table में जोड़ता है.

इस तरीके से, टेबल के बाद एक खाली पैराग्राफ़ भी जुड़ जाएगा. ऐसा इसलिए, क्योंकि Google Docs दस्तावेज़ों में टेबल के बाद कुछ न कुछ टेक्स्ट होना ज़रूरी है.

पैरामीटर

नामटाइपब्यौरा
cellsString[][]नई टेबल में जोड़ने के लिए, टेबल सेल का टेक्स्ट कॉन्टेंट.

वापसी का टिकट

Table — जोड़ी गई टेबल.

अनुमति देना

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

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

appendTable(table)

दिए गए Table को जोड़ता है.

मौजूदा Table की कॉपी जोड़ने के लिए, appendTable के इस वर्शन का इस्तेमाल करें. इस तरीके से, टेबल के बाद एक खाली पैराग्राफ़ भी जुड़ जाएगा. ऐसा इसलिए, क्योंकि Google Docs दस्तावेज़ों में टेबल के बाद कुछ न कुछ टेक्स्ट होना ज़रूरी है.

पैरामीटर

नामटाइपब्यौरा
tableTableजोड़ी जाने वाली टेबल.

वापसी का टिकट

Table — जोड़ी गई टेबल.

अनुमति देना

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

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

clear()

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

वापसी का टिकट

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


copy()

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

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

वापसी का टिकट

HeaderSection — नई कॉपी.

अनुमति देना

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

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

editAsText()

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

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

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

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

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

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

वापसी का टिकट

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


findElement(elementType)

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

पैरामीटर

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

वापसी का टिकट

RangeElement|null — खोज के नतीजे में, खोज के एलिमेंट की जगह के बारे में जानकारी देने वाला सर्च एलिमेंट.

अनुमति देना

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

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

findElement(elementType, from)

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

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

// Define the search parameters.

let searchResult = null;

// Search until the paragraph is found.
while (
    (searchResult = body.findElement(
         DocumentApp.ElementType.PARAGRAPH,
         searchResult,
         ))) {
  const par = searchResult.getElement().asParagraph();
  if (par.getHeading() === DocumentApp.ParagraphHeading.HEADING1) {
    // Found one, update and stop.
    par.setText('This is the first header.');
    break;
  }
}

पैरामीटर

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

वापसी का टिकट

RangeElement|null — खोज के नतीजे में, खोज के एलिमेंट की अगली पोज़िशन के बारे में जानकारी देने वाला नतीजा.

अनुमति देना

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

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

findText(searchPattern)

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

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

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

पैरामीटर

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

वापसी का टिकट

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

अनुमति देना

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

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

findText(searchPattern, from)

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

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

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

पैरामीटर

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

वापसी का टिकट

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

अनुमति देना

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

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

getAttributes()

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

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

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

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

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

// Log the paragraph attributes.
for (const att in atts) {
  Logger.log(`${att}:${atts[att]}`);
}

वापसी का टिकट

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

अनुमति देना

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

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

getChild(childIndex)

यह फ़ंक्शन, दिए गए चाइल्ड इंडेक्स पर मौजूद चाइल्ड एलिमेंट को वापस लाता है.

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

// Obtain the first element in the tab.
const 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

getImages()

इस सेक्शन में मौजूद सभी InlineImages को वापस लाता है.

वापसी का टिकट

InlineImage[]|null — सेक्शन की इमेज.

अनुमति देना

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

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

getListItems()

इस सेक्शन में मौजूद सभी ListItems को वापस लाता है.

वापसी का टिकट

ListItem[]|null — सेक्शन की सूची में मौजूद आइटम.

अनुमति देना

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

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

getNumChildren()

इससे बच्चों की संख्या मिलती है.

const 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

getParagraphs()

सेक्शन में मौजूद सभी Paragraphs (इसमें ListItems भी शामिल है) को वापस लाता है.

वापसी का टिकट

Paragraph[]|null — सेक्शन के पैराग्राफ़.

अनुमति देना

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

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

getParent()

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

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

वापसी का टिकट

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

अनुमति देना

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

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

getTables()

इस सेक्शन में मौजूद सभी Tables को वापस लाता है.

वापसी का टिकट

Table[]|null — सेक्शन टेबल.

अनुमति देना

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

  • 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 — टेक्स्ट अलाइनमेंट का टाइप या null अगर टेक्स्ट में कई तरह के टेक्स्ट अलाइनमेंट शामिल हैं या टेक्स्ट अलाइनमेंट कभी सेट नहीं किया गया है

अनुमति देना

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

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

getType()

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

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

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

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

const firstChild = body.getChild(0);

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

वापसी का टिकट

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

अनुमति देना

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

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

insertHorizontalRule(childIndex)

यह तय किए गए इंडेक्स पर, नया HorizontalRule बनाता है और उसे डालता है.

HorizontalRule को एक नए Paragraph में शामिल किया जाएगा.

पैरामीटर

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

वापसी का टिकट

HorizontalRule — नया हॉरिज़ॉन्टल रूल.

अनुमति देना

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

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

insertImage(childIndex, image)

यह फ़ंक्शन, तय किए गए इंडेक्स पर, तय की गई इमेज के बड़े ऑब्जेक्ट से InlineImage बनाता है और उसे शामिल करता है.

पैरामीटर

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

वापसी का टिकट

InlineImage — यह जोड़ी गई इनलाइन इमेज है.

अनुमति देना

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

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

insertImage(childIndex, image)

यह फ़ंक्शन, दिए गए इंडेक्स पर InlineImage को शामिल करता है.

इमेज को एक नए Paragraph में शामिल किया जाएगा.

पैरामीटर

नामटाइपब्यौरा
childIndexIntegerवह इंडेक्स जहां एलिमेंट को शामिल करना है.
imageInlineImageशामिल की जाने वाली इमेज.

वापसी का टिकट

InlineImage — यह जोड़ी गई इनलाइन इमेज है.

अनुमति देना

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

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

insertListItem(childIndex, listItem)

यह फ़ंक्शन, दिए गए इंडेक्स पर ListItem को शामिल करता है.

पैरामीटर

नामटाइपब्यौरा
childIndexIntegerवह इंडेक्स जहां वैल्यू को शामिल करना है.
listItemListItemसूची में शामिल किया जाने वाला आइटम.

वापसी का टिकट

ListItem — सूची में शामिल किया गया आइटम.

अनुमति देना

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

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

insertListItem(childIndex, text)

यह तय किए गए इंडेक्स पर एक नया ListItem बनाता है और उसे डालता है. इसमें तय किया गया टेक्स्ट कॉन्टेंट होता है.

पैरामीटर

नामटाइपब्यौरा
childIndexIntegerवह इंडेक्स जहां वैल्यू को शामिल करना है.
textStringसूची के आइटम का टेक्स्ट कॉन्टेंट.

वापसी का टिकट

ListItem — सूची में जोड़ा गया नया आइटम.

अनुमति देना

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

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

insertParagraph(childIndex, paragraph)

यह फ़ंक्शन, दिए गए इंडेक्स पर Paragraph को शामिल करता है.

पैरामीटर

नामटाइपब्यौरा
childIndexIntegerवह इंडेक्स जहां आइटम को शामिल करना है.
paragraphParagraphवह पैराग्राफ़ जिसे डालना है.

वापसी का टिकट

Paragraph — डाला गया पैराग्राफ़.

अनुमति देना

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

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

insertParagraph(childIndex, text)

यह तय किए गए इंडेक्स पर एक नया Paragraph बनाता है और उसे डालता है. इसमें तय किया गया टेक्स्ट कॉन्टेंट होता है.

पैरामीटर

नामटाइपब्यौरा
childIndexIntegerवह इंडेक्स जहां वैल्यू को शामिल करना है.
textStringपैराग्राफ़ का टेक्स्ट कॉन्टेंट.

वापसी का टिकट

Paragraph — नया पैराग्राफ़.

अनुमति देना

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

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

insertTable(childIndex)

यह तय किए गए इंडेक्स पर, नया Table बनाता है और उसे डालता है.

पैरामीटर

नामटाइपब्यौरा
childIndexIntegerवह इंडेक्स जहां वैल्यू को शामिल करना है.

वापसी का टिकट

Table — नई टेबल.

अनुमति देना

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

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

insertTable(childIndex, cells)

यह फ़ंक्शन, तय किए गए इंडेक्स पर, तय की गई सेल वाला नया Table बनाता है और उसे डालता है.

पैरामीटर

नामटाइपब्यौरा
childIndexIntegerवह इंडेक्स जहां वैल्यू को शामिल करना है.
cellsString[][]नई टेबल में जोड़ने के लिए, टेबल सेल का टेक्स्ट कॉन्टेंट.

वापसी का टिकट

Table — नई टेबल.

अनुमति देना

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

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

insertTable(childIndex, table)

यह फ़ंक्शन, दिए गए इंडेक्स पर Table को शामिल करता है.

पैरामीटर

नामटाइपब्यौरा
childIndexIntegerवह इंडेक्स जहां वैल्यू को शामिल करना है.
tableTableवह टेबल जिसे शामिल करना है.

वापसी का टिकट

Table — यह शामिल की गई टेबल है.

अनुमति देना

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

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

removeChild(child)

यह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट को हटाता है.

पैरामीटर

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

वापसी का टिकट

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

अनुमति देना

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

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

removeFromParent()

इस फ़ंक्शन का इस्तेमाल करके, एलिमेंट को उसके पैरंट से हटाया जा सकता है.

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

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

वापसी का टिकट

HeaderSection|null — हटाया गया एलिमेंट.

अनुमति देना

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

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

replaceText(searchPattern, replacement)

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

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

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

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

const 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 इन्यूमरेशन में मौजूद एक आइटम होता है. साथ ही, हर प्रॉपर्टी की वैल्यू, लागू की जाने वाली नई वैल्यू होती है.

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

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

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

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

पैरामीटर

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

वापसी का टिकट

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

अनुमति देना

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

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

setText(text)

इससे कॉन्टेंट को सामान्य टेक्स्ट के तौर पर सेट किया जाता है.

ध्यान दें: मौजूदा कॉन्टेंट मिटा दिया जाता है.

पैरामीटर

नामटाइपब्यौरा
textStringनया टेक्स्ट कॉन्टेंट.

वापसी का टिकट

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

अनुमति देना

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

  • 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.
const documentTab =
    DocumentApp.getActiveDocument().getActiveTab().asDocumentTab();
const text = documentTab.getBody().getParagraphs()[0].editAsText();
text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);

पैरामीटर

नामटाइपब्यौरा
textAlignmentTextAlignmentटेक्स्ट अलाइनमेंट का टाइप

वापसी का टिकट

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

अनुमति देना

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

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

ऐसे तरीके जिन्हें अब इस्तेमाल नहीं किया जा सकता