Class Body

Body

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

Body में आम तौर पर, पूरे टैब का कॉन्टेंट शामिल होता है. हालांकि, इसमें HeaderSection, FooterSection, और FootnoteSection एलिमेंट शामिल नहीं होते.

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

// Append a paragraph and a page break to the tab's body section directly.
body.appendParagraph('A paragraph.');
body.appendPageBreak();

तरीके

तरीकारिटर्न टाइपसंक्षिप्त विवरण
appendHorizontalRule()HorizontalRuleयह एक नया HorizontalRule बनाता है और उसे जोड़ता है.
appendImage(image)InlineImageयह फ़ंक्शन, दी गई इमेज के बड़े बाइनरी ऑब्जेक्ट (ब्लॉब) से नया InlineImage बनाता है और उसे जोड़ता है.
appendImage(image)InlineImageयह दिए गए InlineImage को जोड़ता है.
appendListItem(listItem)ListItemयह दिए गए ListItem को जोड़ता है.
appendListItem(text)ListItemयह फ़ंक्शन, तय किए गए टेक्स्ट कॉन्टेंट वाला नया ListItem बनाता है और उसे जोड़ता है.
appendPageBreak()PageBreakयह एक नया PageBreak बनाता है और उसे जोड़ता है.
appendPageBreak(pageBreak)PageBreakयह दिए गए PageBreak को जोड़ता है.
appendParagraph(paragraph)Paragraphयह दिए गए Paragraph को जोड़ता है.
appendParagraph(text)Paragraphयह फ़ंक्शन, तय किए गए टेक्स्ट कॉन्टेंट वाला नया Paragraph बनाता है और उसे जोड़ता है.
appendTable()Tableयह एक नया Table बनाता है और उसे जोड़ता है.
appendTable(cells)Tableयह फ़ंक्शन, हर स्ट्रिंग वैल्यू के लिए एक TableCell बनाता है और उसे नए Table में जोड़ता है.
appendTable(table)Tableयह दिए गए Table को जोड़ता है.
clear()Bodyइस तरीके से, एलिमेंट का कॉन्टेंट मिट जाता है.
copy()Bodyयह फ़ंक्शन, मौजूदा एलिमेंट की अलग की गई डीप कॉपी दिखाता है.
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यह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट के लिए चाइल्ड इंडेक्स को वापस लाता है.
getHeadingAttributes(paragraphHeading)Objectयह फ़ंक्शन, दिए गए ParagraphHeading के लिए एट्रिब्यूट का सेट वापस लाता है.
getImages()InlineImage[]|nullइस सेक्शन में मौजूद सभी InlineImages को वापस लाता है.
getListItems()ListItem[]|nullइस सेक्शन में मौजूद सभी ListItems को वापस लाता है.
getMarginBottom()Number|nullयह फ़ंक्शन, सबसे नीचे वाले मार्जिन को पॉइंट में दिखाता है.
getMarginLeft()Number|nullयह बाईं ओर के मार्जिन को पॉइंट में दिखाता है.
getMarginRight()Number|nullयह फ़ंक्शन, राइट मार्जिन को वापस लाता है.
getMarginTop()Number|nullयह टॉप मार्जिन को वापस लाता है.
getNumChildren()Integerयह कुकी, बच्चों की संख्या को वापस लाती है.
getPageHeight()Number|nullयह पेज की लंबाई को पॉइंट में दिखाता है.
getPageWidth()Number|nullयह पेज की चौड़ाई को पॉइंट में दिखाता है.
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 बनाता है और उसे डालता है. इसमें तय किया गया टेक्स्ट कॉन्टेंट होता है.
insertPageBreak(childIndex)PageBreakयह तय किए गए इंडेक्स पर, नया PageBreak बनाता है और उसे डालता है.
insertPageBreak(childIndex, pageBreak)PageBreakयह फ़ंक्शन, दिए गए इंडेक्स पर PageBreak को जोड़ता है.
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)Bodyयह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट को हटाता है.
replaceText(searchPattern, replacement)Elementरेगुलर एक्सप्रेशन का इस्तेमाल करके, दिए गए टेक्स्ट पैटर्न की सभी जगहों पर, दिए गए रिप्लेसमेंट स्ट्रिंग को बदलता है.
setAttributes(attributes)Bodyयह एलिमेंट के एट्रिब्यूट सेट करता है.
setHeadingAttributes(paragraphHeading, attributes)Bodyयह फ़ंक्शन, दिए गए ParagraphHeading के लिए एट्रिब्यूट सेट करता है.
setMarginBottom(marginBottom)Bodyयह विकल्प, निचले मार्जिन को पॉइंट में सेट करता है.
setMarginLeft(marginLeft)Bodyयह विकल्प, बाएं मार्जिन को पॉइंट में सेट करता है.
setMarginRight(marginRight)Bodyयह विकल्प, दायां मार्जिन सेट करता है. इसकी वैल्यू पॉइंट में होती है.
setMarginTop(marginTop)Bodyयह विकल्प, सबसे ऊपर के मार्जिन को सेट करता है.
setPageHeight(pageHeight)Bodyइससे पेज की ऊंचाई पॉइंट में सेट की जाती है.
setPageWidth(pageWidth)Bodyयह विकल्प, पेज की चौड़ाई को पॉइंट में सेट करता है.
setText(text)Bodyइससे कॉन्टेंट को सामान्य टेक्स्ट के तौर पर सेट किया जाता है.
setTextAlignment(textAlignment)Bodyइससे टेक्स्ट अलाइनमेंट सेट किया जाता है.

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

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

appendPageBreak()

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

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

वापसी का टिकट

PageBreak — नया पेज ब्रेक.

अनुमति देना

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

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

appendPageBreak(pageBreak)

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

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

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

पैरामीटर

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

वापसी का टिकट

PageBreak — जोड़ा गया पेज ब्रेक.

अनुमति देना

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

  • 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()

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

वापसी का टिकट

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


copy()

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

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

वापसी का टिकट

Body — नई कॉपी.

अनुमति देना

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

  • 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

getHeadingAttributes(paragraphHeading)

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

पैरामीटर

नामटाइपब्यौरा
paragraphHeadingParagraphHeadingवह हेडिंग जिसके एट्रिब्यूट वापस पाने हैं.

वापसी का टिकट

Object — एट्रिब्यूट और उनकी मौजूदा वैल्यू का मैप.

अनुमति देना

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

  • 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

getMarginBottom()

यह फ़ंक्शन, सबसे नीचे वाले मार्जिन को पॉइंट में दिखाता है.

वापसी का टिकट

Number|null — सबसे नीचे वाला मार्जिन, पॉइंट में.

अनुमति देना

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

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

getMarginLeft()

यह बाईं ओर के मार्जिन को पॉइंट में दिखाता है.

वापसी का टिकट

Number|null — यह बाएं मार्जिन को पॉइंट में दिखाता है.

अनुमति देना

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

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

getMarginRight()

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

वापसी का टिकट

Number|null — यह दाईं ओर का मार्जिन है, जो पॉइंट में होता है.

अनुमति देना

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

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

getMarginTop()

यह टॉप मार्जिन को वापस लाता है.

वापसी का टिकट

Number|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

getPageHeight()

यह पेज की लंबाई को पॉइंट में दिखाता है.

वापसी का टिकट

Number|null — पेज की ऊंचाई, पॉइंट में.

अनुमति देना

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

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

getPageWidth()

यह पेज की चौड़ाई को पॉइंट में दिखाता है.

वापसी का टिकट

Number|null — पेज की चौड़ाई, पॉइंट में.

अनुमति देना

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

  • 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

insertPageBreak(childIndex)

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

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

पैरामीटर

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

वापसी का टिकट

PageBreak — नया पेज ब्रेक.

अनुमति देना

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

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

insertPageBreak(childIndex, pageBreak)

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

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

पैरामीटर

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

वापसी का टिकट

PageBreak — डाला गया पेज ब्रेक.

अनुमति देना

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

  • 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हटाया जाने वाला चाइल्ड एलिमेंट.

वापसी का टिकट

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

अनुमति देना

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

  • 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एलिमेंट के एट्रिब्यूट.

वापसी का टिकट

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

अनुमति देना

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

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

setHeadingAttributes(paragraphHeading, attributes)

यह फ़ंक्शन, दिए गए ParagraphHeading के लिए एट्रिब्यूट सेट करता है.

पैरामीटर

नामटाइपब्यौरा
paragraphHeadingParagraphHeadingवह हेडिंग जिसके एट्रिब्यूट सेट किए जाने चाहिए.
attributesObjectएट्रिब्यूट और उनकी वैल्यू का मैप.

वापसी का टिकट

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

अनुमति देना

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

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

setMarginBottom(marginBottom)

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

पैरामीटर

नामटाइपब्यौरा
marginBottomNumberसबसे नीचे का मार्जिन, पॉइंट में.

वापसी का टिकट

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

अनुमति देना

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

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

setMarginLeft(marginLeft)

यह विकल्प, बाएं मार्जिन को पॉइंट में सेट करता है.

पैरामीटर

नामटाइपब्यौरा
marginLeftNumberबायां मार्जिन, पॉइंट में.

वापसी का टिकट

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

अनुमति देना

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

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

setMarginRight(marginRight)

यह विकल्प, दायां मार्जिन सेट करता है. इसकी वैल्यू पॉइंट में होती है.

पैरामीटर

नामटाइपब्यौरा
marginRightNumberदायां मार्जिन.

वापसी का टिकट

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

अनुमति देना

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

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

setMarginTop(marginTop)

यह विकल्प, सबसे ऊपर के मार्जिन को सेट करता है.

पैरामीटर

नामटाइपब्यौरा
marginTopNumberसबसे ऊपर वाला मार्जिन, पॉइंट में.

वापसी का टिकट

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

अनुमति देना

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

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

setPageHeight(pageHeight)

इससे पेज की ऊंचाई पॉइंट में सेट की जाती है.

पैरामीटर

नामटाइपब्यौरा
pageHeightNumberपेज की लंबाई, पॉइंट में.

वापसी का टिकट

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

अनुमति देना

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

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

setPageWidth(pageWidth)

यह विकल्प, पेज की चौड़ाई को पॉइंट में सेट करता है.

पैरामीटर

नामटाइपब्यौरा
pageWidthNumberपेज की चौड़ाई, पॉइंट में.

वापसी का टिकट

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

अनुमति देना

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

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

setText(text)

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

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

पैरामीटर

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

वापसी का टिकट

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

अनुमति देना

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

  • 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टेक्स्ट अलाइनमेंट का वह टाइप जिसे लागू करना है

वापसी का टिकट

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

अनुमति देना

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

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

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