Class Text

टेक्स्ट

रिच टेक्स्ट वाले क्षेत्र को दिखाने वाला एलिमेंट. Document में मौजूद सभी टेक्स्ट, Text एलिमेंट में शामिल होते हैं. Text एलिमेंट को Equation, EquationFunction, ListItem या Paragraph में शामिल किया जा सकता है. हालांकि, इसमें कोई अन्य एलिमेंट शामिल नहीं किया जा सकता. दस्तावेज़ के स्ट्रक्चर के बारे में ज़्यादा जानकारी के लिए, Google Docs को एक्सटेंड करने से जुड़ी गाइड देखें.

// Gets the body contents of the active tab.
const body =
    DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Use editAsText to obtain a single text element containing
// all the characters in the tab.
const text = body.editAsText();

// Insert text at the beginning of the tab.
text.insertText(0, 'Inserted text.\n');

// Insert text at the end of the tab.
text.appendText('\nAppended text.');

// Make the first half of the tab blue.
text.setForegroundColor(0, text.getText().length / 2, '#00FFFF');

तरीके

तरीकारिटर्न टाइपसंक्षिप्त विवरण
appendText(text)Textइस टेक्स्ट रीजन के आखिर में, तय किया गया टेक्स्ट जोड़ता है.
copy()Textयह फ़ंक्शन, मौजूदा एलिमेंट की अलग की गई डीप कॉपी दिखाता है.
deleteText(startOffset, endOffsetInclusive)Textटेक्स्ट की किसी रेंज को मिटाता है.
editAsText()Textबदलाव करने के लिए, मौजूदा एलिमेंट का Text वर्शन मिलता है.
findText(searchPattern)RangeElement|nullरेगुलर एक्सप्रेशन का इस्तेमाल करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है.
findText(searchPattern, from)RangeElement|nullयह फ़ंक्शन, दिए गए खोज नतीजे से शुरू करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है.
getAttributes()Objectयह एलिमेंट के एट्रिब्यूट वापस लाता है.
getAttributes(offset)Objectइससे, तय किए गए वर्ण ऑफ़सेट पर मौजूद एट्रिब्यूट मिलते हैं.
getBackgroundColor()String|nullबैकग्राउंड के रंग की सेटिंग वापस लाता है.
getBackgroundColor(offset)String|nullइससे, तय किए गए वर्ण ऑफ़सेट पर बैकग्राउंड का रंग मिलता है.
getFontFamily()String|nullयह फ़ॉन्ट फ़ैमिली की सेटिंग को वापस लाता है.
getFontFamily(offset)String|nullइससे, तय किए गए वर्ण ऑफ़सेट पर मौजूद फ़ॉन्ट फ़ैमिली मिलती है.
getFontSize()Number|nullइससे फ़ॉन्ट के साइज़ की सेटिंग मिलती है.
getFontSize(offset)Number|nullइससे, तय किए गए वर्ण ऑफ़सेट पर फ़ॉन्ट का साइज़ मिलता है.
getForegroundColor()String|nullफ़ोरग्राउंड के रंग की सेटिंग वापस लाता है.
getForegroundColor(offset)String|nullइससे, तय किए गए वर्ण ऑफ़सेट पर फ़ोरग्राउंड का रंग मिलता है.
getLinkUrl()String|nullयह कुकी, लिंक का यूआरएल वापस पाती है.
getLinkUrl(offset)String|nullइससे, तय किए गए वर्ण ऑफ़सेट पर मौजूद लिंक का यूआरएल मिलता है.
getNextSibling()Element|nullयह एलिमेंट के अगले सिबलिंग एलिमेंट को वापस लाता है.
getParent()ContainerElement|nullयह एलिमेंट के पैरंट एलिमेंट को वापस लाता है.
getPreviousSibling()Element|nullयह एलिमेंट के पिछले समरूप एलिमेंट को वापस लाता है.
getText()Stringयह फ़ंक्शन, एलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर वापस लाता है.
getTextAlignment()TextAlignment|nullटेक्स्ट अलाइनमेंट की जानकारी मिलती है.
getTextAlignment(offset)TextAlignment|nullकिसी वर्ण के लिए टेक्स्ट अलाइनमेंट की जानकारी मिलती है.
getTextAttributeIndices()Integer[]यह फ़ंक्शन, टेक्स्ट इंडेक्स का वह सेट वापस लाता है जो टेक्स्ट फ़ॉर्मैटिंग के अलग-अलग रन की शुरुआत से मेल खाता है.
getType()ElementTypeयह एलिमेंट के ElementType को वापस लाता है.
insertText(offset, text)Textइससे, दिए गए वर्ण ऑफ़सेट पर बताया गया टेक्स्ट डाला जाता है.
isAtDocumentEnd()Booleanइससे यह तय होता है कि एलिमेंट, Document के आखिर में है या नहीं.
isBold()Boolean|nullबोल्ड सेटिंग को वापस लाता है.
isBold(offset)Boolean|nullइससे, तय किए गए वर्ण ऑफ़सेट पर बोल्ड सेटिंग मिलती है.
isItalic()Boolean|nullइटैलिक सेटिंग वापस लाता है.
isItalic(offset)Boolean|nullइससे, दिए गए वर्ण ऑफ़सेट पर इटैलिक सेटिंग मिलती है.
isStrikethrough()Boolean|nullइस तरीके से, स्ट्राइकथ्रू सेटिंग को वापस पाया जाता है.
isStrikethrough(offset)Boolean|nullइससे, दिए गए वर्ण के ऑफ़सेट पर स्ट्राइकथ्रू सेटिंग मिलती है.
isUnderline()Boolean|nullइस कुकी का इस्तेमाल, अंडरलाइन की सेटिंग को वापस पाने के लिए किया जाता है.
isUnderline(offset)Boolean|nullइससे, तय किए गए वर्ण ऑफ़सेट पर अंडरलाइन की सेटिंग मिलती है.
merge()Text|nullइस विकल्प का इस्तेमाल करके, एलिमेंट को उसी तरह के पिछले एलिमेंट के साथ मर्ज किया जाता है.
removeFromParent()Text|nullइस तरीके का इस्तेमाल करके, एलिमेंट को उसके पैरंट से हटाया जा सकता है.
replaceText(searchPattern, replacement)Elementरेगुलर एक्सप्रेशन का इस्तेमाल करके, दिए गए टेक्स्ट पैटर्न की सभी जगहों पर, दिए गए रिप्लेसमेंट स्ट्रिंग को बदलता है.
setAttributes(startOffset, endOffsetInclusive, attributes)Textयह फ़ंक्शन, वर्णों की दी गई रेंज पर तय किए गए एट्रिब्यूट लागू करता है.
setAttributes(attributes)Textयह एलिमेंट के एट्रिब्यूट सेट करता है.
setBackgroundColor(startOffset, endOffsetInclusive, color)Textइससे, तय की गई वर्ण सीमा के लिए बैकग्राउंड का रंग सेट किया जाता है.
setBackgroundColor(color)Textबैकग्राउंड का रंग सेट करता है.
setBold(bold)Textइससे बोल्ड सेटिंग सेट की जाती है.
setBold(startOffset, endOffsetInclusive, bold)Textइससे, वर्णों की चुनी गई रेंज के लिए बोल्ड सेटिंग सेट की जाती है.
setFontFamily(startOffset, endOffsetInclusive, fontFamilyName)Textइससे तय किए गए वर्णों की रेंज के लिए फ़ॉन्ट फ़ैमिली सेट की जाती है.
setFontFamily(fontFamilyName)Textइससे फ़ॉन्ट फ़ैमिली सेट की जाती है.
setFontSize(startOffset, endOffsetInclusive, size)Textइससे वर्णों की तय की गई रेंज के लिए फ़ॉन्ट का साइज़ सेट किया जाता है.
setFontSize(size)Textइससे फ़ॉन्ट का साइज़ सेट किया जाता है.
setForegroundColor(startOffset, endOffsetInclusive, color)Textइससे तय किए गए वर्णों की रेंज के लिए, फ़ोरग्राउंड का रंग सेट किया जाता है.
setForegroundColor(color)Textइससे फ़ोरग्राउंड का रंग सेट किया जाता है.
setItalic(italic)Textइससे इटैलिक सेटिंग सेट की जाती है.
setItalic(startOffset, endOffsetInclusive, italic)Textइससे, वर्णों की तय की गई रेंज के लिए इटैलिक सेटिंग सेट की जाती है.
setLinkUrl(startOffset, endOffsetInclusive, url)Textयह विकल्प, वर्णों की तय की गई रेंज के लिए लिंक यूआरएल सेट करता है.
setLinkUrl(url)Textयह कुकी, लिंक किए गए यूआरएल को सेट करती है.
setStrikethrough(strikethrough)Textइस विकल्प का इस्तेमाल करके, स्ट्राइकथ्रू सेटिंग सेट की जाती है.
setStrikethrough(startOffset, endOffsetInclusive, strikethrough)Textइससे, वर्णों की तय की गई रेंज के लिए स्ट्राइकथ्रू सेटिंग सेट की जाती है.
setText(text)Textइस विकल्प से, टेक्स्ट का कॉन्टेंट सेट किया जाता है.
setTextAlignment(startOffset, endOffsetInclusive, textAlignment)Textइससे वर्णों की दी गई रेंज के लिए, टेक्स्ट अलाइनमेंट सेट किया जाता है.
setTextAlignment(textAlignment)Textइससे टेक्स्ट अलाइनमेंट सेट किया जाता है.
setUnderline(underline)Textइस विकल्प का इस्तेमाल, अंडरलाइन की सेटिंग सेट करने के लिए किया जाता है.
setUnderline(startOffset, endOffsetInclusive, underline)Textइससे, वर्णों की तय की गई रेंज के लिए अंडरलाइन की सेटिंग सेट की जाती है.

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

appendText(text)

इस टेक्स्ट रीजन के आखिर में, तय किया गया टेक्स्ट जोड़ता है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Adds the text, 'Sample body text,' to the end of the tab body.
const text = body.editAsText().appendText('Sample body text');

पैरामीटर

नामटाइपब्यौरा
textStringजोड़ने के लिए टेक्स्ट.

वापसी का टिकट

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

अनुमति देना

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

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

copy()

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

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

वापसी का टिकट

Text — नई कॉपी.

अनुमति देना

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

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

deleteText(startOffset, endOffsetInclusive)

टेक्स्ट की किसी रेंज को मिटाता है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Deletes the first 10 characters in the body.
const text = body.editAsText().deleteText(0, 9);

पैरामीटर

नामटाइपब्यौरा
startOffsetIntegerमिटाए जाने वाले पहले वर्ण का ऑफ़सेट.
endOffsetInclusiveIntegerमिटाए जाने वाले आखिरी वर्ण का ऑफ़सेट.

वापसी का टिकट

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

अनुमति देना

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

  • 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 — मौजूदा एलिमेंट का टेक्स्ट वर्शन


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

getAttributes(offset)

इससे, तय किए गए वर्ण ऑफ़सेट पर मौजूद एट्रिब्यूट मिलते हैं.

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

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Declares style attributes.
const style = {};
style[DocumentApp.Attribute.BOLD] = true;
style[DocumentApp.Attribute.ITALIC] = true;
style[DocumentApp.Attribute.FONT_SIZE] = 29;

// Sets the style attributes to the tab's body.
const text = body.editAsText();
text.setAttributes(style);

// Gets the style attributes applied to the eleventh character in the
// body and logs them to the console.
const attributes = text.getAttributes(10);
console.log(attributes);

पैरामीटर

नामटाइपब्यौरा
offsetIntegerवर्ण ऑफ़सेट.

वापसी का टिकट

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

अनुमति देना

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

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

getBackgroundColor()

बैकग्राउंड के रंग की सेटिंग वापस लाता है.

वापसी का टिकट

String|null — बैकग्राउंड का रंग, सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया है. अगर एलिमेंट में इस एट्रिब्यूट के लिए एक से ज़्यादा वैल्यू शामिल हैं, तो यह null होगा

अनुमति देना

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

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

getBackgroundColor(offset)

इससे, तय किए गए वर्ण ऑफ़सेट पर बैकग्राउंड का रंग मिलता है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the background color of the first 3 characters in the body.
const text = body.editAsText().setBackgroundColor(0, 2, '#FFC0CB');

// Gets the background color of the first character in the body.
const backgroundColor = text.getBackgroundColor(0);

// Logs the background color to the console.
console.log(backgroundColor);

पैरामीटर

नामटाइपब्यौरा
offsetIntegerवर्ण ऑफ़सेट.

वापसी का टिकट

String|null — बैकग्राउंड का रंग, जिसे सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया है.

अनुमति देना

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

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

getFontFamily()

यह फ़ॉन्ट फ़ैमिली की सेटिंग को वापस लाता है. नाम, Docs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू में से किसी भी फ़ॉन्ट का हो सकता है. यह केस-सेंसिटिव होता है. getFontFamily() और setFontFamily(fontFamilyName) तरीके अब FontFamily enum के बजाय, फ़ॉन्ट के लिए स्ट्रिंग नामों का इस्तेमाल करते हैं. हालांकि, इस enum को अब इस्तेमाल नहीं किया जा सकता, लेकिन यह पुरानी स्क्रिप्ट के साथ काम करता रहेगा.

वापसी का टिकट

String|null — फ़ॉन्ट फ़ैमिली या अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो null

अनुमति देना

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

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

getFontFamily(offset)

इससे, तय किए गए वर्ण ऑफ़सेट पर मौजूद फ़ॉन्ट फ़ैमिली मिलती है. नाम, Docs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू में से किसी भी फ़ॉन्ट का हो सकता है. साथ ही, यह केस-सेंसिटिव होता है. अब getFontFamily() और setFontFamily(fontFamilyName) तरीकों में, फ़ॉन्ट के लिए FontFamily enum के बजाय स्ट्रिंग नामों का इस्तेमाल किया जाता है. हालांकि, इस enum को अब इस्तेमाल नहीं किया जा सकता, लेकिन यह पुरानी स्क्रिप्ट के साथ काम करता रहेगा.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the font of the first 16 characters to Impact.
const text = body.editAsText().setFontFamily(0, 15, 'Impact');

// Gets the font family of the 16th character in the tab body.
const fontFamily = text.getFontFamily(15);

// Logs the font family to the console.
console.log(fontFamily);

पैरामीटर

नामटाइपब्यौरा
offsetIntegerवर्ण ऑफ़सेट.

वापसी का टिकट

String|null — फ़ॉन्ट फ़ैमिली.

अनुमति देना

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

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

getFontSize()

यह कुकी, फ़ॉन्ट के साइज़ की सेटिंग को वापस लाती है.

वापसी का टिकट

Number|null — फ़ॉन्ट का साइज़ या अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो शून्य

अनुमति देना

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

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

getFontSize(offset)

इससे, तय किए गए वर्ण ऑफ़सेट पर फ़ॉन्ट का साइज़ मिलता है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the font size of the first 13 characters to 15.
const text = body.editAsText().setFontSize(0, 12, 15);

// Gets the font size of the first character.
const fontSize = text.getFontSize(0);

// Logs the font size to the console.
console.log(fontSize);

पैरामीटर

नामटाइपब्यौरा
offsetIntegerवर्ण ऑफ़सेट.

वापसी का टिकट

Number|null — फ़ॉन्ट का साइज़.

अनुमति देना

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

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

getForegroundColor()

फ़ोरग्राउंड के रंग की सेटिंग वापस लाता है.

वापसी का टिकट

String|null — फ़ोरग्राउंड का रंग, सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया है. अगर एलिमेंट में इस एट्रिब्यूट के लिए एक से ज़्यादा वैल्यू शामिल हैं, तो यह null होगा

अनुमति देना

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

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

getForegroundColor(offset)

इससे, तय किए गए वर्ण ऑफ़सेट पर फ़ोरग्राउंड का रंग मिलता है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the foreground color of the first 3 characters in the tab body.
const text = body.editAsText().setForegroundColor(0, 2, '#0000FF');

// Gets the foreground color of the first character in the tab body.
const foregroundColor = text.getForegroundColor(0);

// Logs the foreground color to the console.
console.log(foregroundColor);

पैरामीटर

नामटाइपब्यौरा
offsetIntegerवर्ण ऑफ़सेट.

वापसी का टिकट

String|null — फ़ोरग्राउंड का रंग, जिसे सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया है.

अनुमति देना

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

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

getLinkUrl()

यह कुकी, लिंक का यूआरएल वापस पाती है.

वापसी का टिकट

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

अनुमति देना

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

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

getLinkUrl(offset)

इससे, तय किए गए वर्ण ऑफ़सेट पर मौजूद लिंक का यूआरएल मिलता है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Applies a link to the first 10 characters in the body.
const text = body.editAsText().setLinkUrl(0, 9, 'https://www.example.com/');

// Gets the URL of the link from the first character.
const link = text.getLinkUrl(0);

// Logs the link URL to the console.
console.log(link);

पैरामीटर

नामटाइपब्यौरा
offsetIntegerवर्ण ऑफ़सेट.

वापसी का टिकट

String|null — लिंक का यूआरएल.

अनुमति देना

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

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

getNextSibling()

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

अगले सिबलिंग का पैरंट वही होता है जो मौजूदा एलिमेंट का होता है. साथ ही, यह मौजूदा एलिमेंट के बाद आता है.

वापसी का टिकट

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

getPreviousSibling()

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

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

वापसी का टिकट

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

getTextAlignment(offset)

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

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the text alignment of the tab's body to NORMAL.
const text =
    body.editAsText().setTextAlignment(DocumentApp.TextAlignment.NORMAL);

// Gets the text alignment of the ninth character.
const alignment = text.getTextAlignment(8);

// Logs the text alignment to the console.
console.log(alignment.toString());

पैरामीटर

नामटाइपब्यौरा
offsetIntegerवर्ण का ऑफ़सेट.

वापसी का टिकट

TextAlignment|null — टेक्स्ट अलाइनमेंट का टाइप या null, अगर टेक्स्ट अलाइनमेंट कभी सेट नहीं किया गया है.

अनुमति देना

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

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

getTextAttributeIndices()

यह फ़ंक्शन, टेक्स्ट इंडेक्स का वह सेट वापस लाता है जो टेक्स्ट फ़ॉर्मैटिंग के अलग-अलग रन की शुरुआत से मेल खाता है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Gets the text indices at which text formatting changes.
const indices = body.editAsText().getTextAttributeIndices();

// Logs the indices to the console.
console.log(indices.toString());

वापसी का टिकट

Integer[] — टेक्स्ट इंडेक्स का वह सेट जहां टेक्स्ट फ़ॉर्मैटिंग बदलती है.

अनुमति देना

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

  • 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

insertText(offset, text)

इससे, दिए गए वर्ण ऑफ़सेट पर बताया गया टेक्स्ट डाला जाता है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Inserts the text, 'Sample inserted text', at the start of the body content.
const text = body.editAsText().insertText(0, 'Sample inserted text');

पैरामीटर

नामटाइपब्यौरा
offsetIntegerवर्ण ऑफ़सेट, जहां टेक्स्ट डाला जाना है.
textStringवह टेक्स्ट जिसे शामिल करना है.

वापसी का टिकट

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

अनुमति देना

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

  • 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

isBold()

बोल्ड सेटिंग को वापस लाता है.

वापसी का टिकट

Boolean|null — टेक्स्ट बोल्ड है या नहीं. अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो वैल्यू शून्य होगी

अनुमति देना

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

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

isBold(offset)

इससे, तय किए गए वर्ण ऑफ़सेट पर बोल्ड सेटिंग मिलती है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Bolds the first 4 characters in the tab body.
const text = body.editAsText().setBold(0, 3, true);

// Gets whether or not the text is bold.
const bold = text.editAsText().isBold(0);

// Logs the text's bold setting to the console
console.log(bold);

पैरामीटर

नामटाइपब्यौरा
offsetIntegerवर्ण ऑफ़सेट.

वापसी का टिकट

Boolean|null — बोल्ड सेटिंग.

अनुमति देना

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

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

isItalic()

इटैलिक सेटिंग वापस लाता है.

वापसी का टिकट

Boolean|null — टेक्स्ट इटैलिक है या नहीं. अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो वैल्यू शून्य होगी

अनुमति देना

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

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

isItalic(offset)

इससे, दिए गए वर्ण ऑफ़सेट पर इटैलिक सेटिंग मिलती है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the first 13 characters of the tab body to italic.
const text = body.editAsText().setItalic(0, 12, true);

// Gets whether the fifth character in the tab body is set to
// italic and logs it to the console.
const italic = text.isItalic(4);
console.log(italic);

पैरामीटर

नामटाइपब्यौरा
offsetIntegerवर्ण ऑफ़सेट.

वापसी का टिकट

Boolean|null — इटैलिक सेटिंग.

अनुमति देना

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

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

isStrikethrough()

इस तरीके से, स्ट्राइकथ्रू सेटिंग को वापस पाया जाता है.

वापसी का टिकट

Boolean|null — टेक्स्ट पर काटा गया निशान है या नहीं. अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो वैल्यू शून्य होगी

अनुमति देना

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

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

isStrikethrough(offset)

इससे, दिए गए वर्ण के ऑफ़सेट पर स्ट्राइकथ्रू सेटिंग मिलती है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the first 17 characters of the tab body to strikethrough.
const text = body.editAsText().setStrikethrough(0, 16, true);

// Gets whether the first character in the tab body is set to
// strikethrough and logs it to the console.
const strikethrough = text.isStrikethrough(0);
console.log(strikethrough);

पैरामीटर

नामटाइपब्यौरा
offsetIntegerवर्ण ऑफ़सेट.

वापसी का टिकट

Boolean|null — स्ट्राइकथ्रू सेटिंग.

अनुमति देना

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

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

isUnderline()

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

वापसी का टिकट

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

अनुमति देना

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

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

isUnderline(offset)

इससे, तय किए गए वर्ण ऑफ़सेट पर अंडरलाइन की सेटिंग मिलती है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the first 13 characters of the tab body to underline.
const text = body.editAsText().setUnderline(0, 12, false);

// Gets whether the first character in the tab body is set to
// underline and logs it to the console
const underline = text.editAsText().isUnderline(0);
console.log(underline);

पैरामीटर

नामटाइपब्यौरा
offsetIntegerवर्ण ऑफ़सेट.

वापसी का टिकट

Boolean|null — अंडरलाइन करने की सेटिंग.

अनुमति देना

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

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

merge()

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

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

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

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

// Example 1: Merge paragraphs
// Append two paragraphs to the document's active tab.
const par1 = body.appendParagraph('Paragraph 1.');
const 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.
const cells = [
  ['Row 1, Cell 1', 'Row 1, Cell 2'],
  ['Row 2, Cell 1', 'Row 2, Cell 2'],
];
// Build a table from the array.
const table = body.appendTable(cells);
// Get the first row in the table.
const row = table.getRow(0);
// Get the two cells in this row.
const cell1 = row.getCell(0);
const cell2 = row.getCell(1);
// Merge the current cell into its preceding sibling element.
const merged = cell2.merge();

वापसी का टिकट

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

अनुमति देना

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

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

वापसी का टिकट

Text|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(startOffset, endOffsetInclusive, attributes)

यह फ़ंक्शन, वर्णों की दी गई रेंज पर तय किए गए एट्रिब्यूट लागू करता है.

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

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Declares style attributes for font size and font family.
const style = {};
style[DocumentApp.Attribute.FONT_SIZE] = 20;
style[DocumentApp.Attribute.FONT_FAMILY] = 'Impact';

// Sets the style attributes to the first 9 characters in the tab's body.
const text = body.setAttributes(0, 8, style);

पैरामीटर

नामटाइपब्यौरा
startOffsetIntegerटेक्स्ट रेंज का शुरुआती ऑफ़सेट.
endOffsetInclusiveIntegerटेक्स्ट रेंज का आखिरी ऑफ़सेट.
attributesObjectएलिमेंट के एट्रिब्यूट.

वापसी का टिकट

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

अनुमति देना

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

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

वापसी का टिकट

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

अनुमति देना

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

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

setBackgroundColor(startOffset, endOffsetInclusive, color)

इससे, तय की गई वर्ण सीमा के लिए बैकग्राउंड का रंग सेट किया जाता है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the background color of the first 3 characters in the
// tab body to hex color #0000FF.
const text = body.editAsText().setBackgroundColor(0, 2, '#0000FF');

पैरामीटर

नामटाइपब्यौरा
startOffsetIntegerटेक्स्ट रेंज का शुरुआती ऑफ़सेट.
endOffsetInclusiveIntegerटेक्स्ट रेंज का आखिरी ऑफ़सेट.
colorStringबैकग्राउंड का रंग, जिसे सीएसएस नोटेशन (जैसे, '#ffffff') में फ़ॉर्मैट किया गया है.

वापसी का टिकट

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

अनुमति देना

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

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

setBackgroundColor(color)

बैकग्राउंड का रंग सेट करता है.

पैरामीटर

नामटाइपब्यौरा
colorStringबैकग्राउंड का रंग, सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया

वापसी का टिकट

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

अनुमति देना

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

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

setBold(bold)

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

पैरामीटर

नामटाइपब्यौरा
boldBooleanबोल्ड सेटिंग

वापसी का टिकट

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

अनुमति देना

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

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

setBold(startOffset, endOffsetInclusive, bold)

इससे, वर्णों की चुनी गई रेंज के लिए बोल्ड सेटिंग सेट की जाती है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the first 11 characters in the tab's body to bold.
const text = body.editAsText().setBold(0, 10, true);

पैरामीटर

नामटाइपब्यौरा
startOffsetIntegerटेक्स्ट रेंज का शुरुआती ऑफ़सेट.
endOffsetInclusiveIntegerटेक्स्ट रेंज का आखिरी ऑफ़सेट.
boldBooleanबोल्ड सेटिंग.

वापसी का टिकट

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

अनुमति देना

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

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

setFontFamily(startOffset, endOffsetInclusive, fontFamilyName)

इससे तय किए गए वर्णों की रेंज के लिए फ़ॉन्ट फ़ैमिली सेट की जाती है. नाम, Docs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू में से कोई भी फ़ॉन्ट हो सकता है. यह केस-सेंसिटिव (बड़े और छोटे अक्षरों में अंतर) होता है. जिन फ़ॉन्ट के नामों की पहचान नहीं की जा सकेगी वे Arial के तौर पर रेंडर होंगे. getFontFamily(offset) और setFontFamily(fontFamilyName) तरीके, अब FontFamily enum के बजाय फ़ॉन्ट के लिए स्ट्रिंग नामों का इस्तेमाल करते हैं. हालांकि, इस enum को अब इस्तेमाल नहीं किया जा सकता, लेकिन यह पुरानी स्क्रिप्ट के साथ काम करता रहेगा.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the font of the first 4 characters in the tab's body to Roboto.
const text = body.editAsText().setFontFamily(0, 3, 'Roboto');

पैरामीटर

नामटाइपब्यौरा
startOffsetIntegerटेक्स्ट रेंज का शुरुआती ऑफ़सेट.
endOffsetInclusiveIntegerटेक्स्ट रेंज का आखिरी ऑफ़सेट.
fontFamilyNameStringDocs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू में जाकर, फ़ॉन्ट फ़ैमिली का नाम.

वापसी का टिकट

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

अनुमति देना

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

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

setFontFamily(fontFamilyName)

इससे फ़ॉन्ट फ़ैमिली सेट की जाती है. नाम, Docs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू में से किसी भी फ़ॉन्ट का हो सकता है. यह केस-सेंसिटिव होता है. जिन फ़ॉन्ट के नामों की पहचान नहीं हो पाएगी वे Arial के तौर पर रेंडर होंगे. getFontFamily() और setFontFamily(fontFamilyName) तरीके, अब FontFamily enum के बजाय फ़ॉन्ट के लिए स्ट्रिंग नामों का इस्तेमाल करते हैं. हालांकि, इस enum को अब इस्तेमाल नहीं किया जा सकता, लेकिन यह पुरानी स्क्रिप्ट के साथ काम करता रहेगा.

पैरामीटर

नामटाइपब्यौरा
fontFamilyNameStringDocs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू से, फ़ॉन्ट फ़ैमिली का नाम

वापसी का टिकट

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

अनुमति देना

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

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

setFontSize(startOffset, endOffsetInclusive, size)

इससे वर्णों की तय की गई रेंज के लिए फ़ॉन्ट का साइज़ सेट किया जाता है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the size of the first 11 characters in the tab's body to 12.
const text = body.editAsText().setFontSize(0, 10, 12);

पैरामीटर

नामटाइपब्यौरा
startOffsetIntegerटेक्स्ट रेंज का शुरुआती ऑफ़सेट.
endOffsetInclusiveIntegerटेक्स्ट रेंज का आखिरी ऑफ़सेट.
sizeNumberफ़ॉन्ट का साइज़.

वापसी का टिकट

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

अनुमति देना

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

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

setFontSize(size)

इससे फ़ॉन्ट का साइज़ सेट किया जाता है.

पैरामीटर

नामटाइपब्यौरा
sizeNumberफ़ॉन्ट का साइज़

वापसी का टिकट

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

अनुमति देना

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

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

setForegroundColor(startOffset, endOffsetInclusive, color)

इससे तय किए गए वर्णों की रेंज के लिए, फ़ोरग्राउंड का रंग सेट किया जाता है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the foreground color of the first 2 characters in the
// tab's body to hex color #FF0000.
const text = body.editAsText().setForegroundColor(0, 1, '#FF0000');

// Gets the foreground color for the second character in the tab's body.
const foregroundColor = text.getForegroundColor(1);

//  Logs the foreground color to the console.
console.log(foregroundColor);

पैरामीटर

नामटाइपब्यौरा
startOffsetIntegerटेक्स्ट रेंज का शुरुआती ऑफ़सेट.
endOffsetInclusiveIntegerटेक्स्ट रेंज का आखिरी ऑफ़सेट.
colorStringफ़ोरग्राउंड का रंग, सीएसएस नोटेशन (जैसे, '#ffffff') में फ़ॉर्मैट किया गया.

वापसी का टिकट

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

अनुमति देना

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

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

setForegroundColor(color)

इससे फ़ोरग्राउंड का रंग सेट किया जाता है.

पैरामीटर

नामटाइपब्यौरा
colorStringफ़ोरग्राउंड का रंग, जिसे सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया हो

वापसी का टिकट

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

अनुमति देना

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

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

setItalic(italic)

इससे इटैलिक सेटिंग सेट की जाती है.

पैरामीटर

नामटाइपब्यौरा
italicBooleanइटैलिक सेटिंग

वापसी का टिकट

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

अनुमति देना

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

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

setItalic(startOffset, endOffsetInclusive, italic)

इससे, वर्णों की तय की गई रेंज के लिए इटैलिक सेटिंग सेट की जाती है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the first 11 characters in the tab's body to italic.
const text = body.editAsText().setItalic(0, 10, true);

पैरामीटर

नामटाइपब्यौरा
startOffsetIntegerटेक्स्ट रेंज का शुरुआती ऑफ़सेट.
endOffsetInclusiveIntegerटेक्स्ट रेंज का आखिरी ऑफ़सेट.
italicBooleanइटैलिक सेटिंग.

वापसी का टिकट

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

अनुमति देना

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

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

setLinkUrl(startOffset, endOffsetInclusive, url)

यह विकल्प, वर्णों की तय की गई रेंज के लिए लिंक यूआरएल सेट करता है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Applies a link to the first 11 characters in the body.
const text = body.editAsText().setLinkUrl(0, 10, 'https://example.com');

पैरामीटर

नामटाइपब्यौरा
startOffsetIntegerटेक्स्ट रेंज का शुरुआती ऑफ़सेट.
endOffsetInclusiveIntegerटेक्स्ट रेंज का आखिरी ऑफ़सेट.
urlStringलिंक का यूआरएल.

वापसी का टिकट

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

अनुमति देना

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

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

setLinkUrl(url)

यह कुकी, लिंक किए गए यूआरएल को सेट करती है.

पैरामीटर

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

वापसी का टिकट

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

अनुमति देना

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

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

setStrikethrough(strikethrough)

इस विकल्प का इस्तेमाल करके, स्ट्राइकथ्रू सेटिंग सेट की जाती है.

पैरामीटर

नामटाइपब्यौरा
strikethroughBooleanस्ट्राइकथ्रू सेटिंग

वापसी का टिकट

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

अनुमति देना

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

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

setStrikethrough(startOffset, endOffsetInclusive, strikethrough)

इससे, वर्णों की तय की गई रेंज के लिए स्ट्राइकथ्रू सेटिंग सेट की जाती है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the first 11 characters in the tab's body to strikethrough.
const text = body.editAsText().setStrikethrough(0, 10, true);

पैरामीटर

नामटाइपब्यौरा
startOffsetIntegerटेक्स्ट रेंज का शुरुआती ऑफ़सेट.
endOffsetInclusiveIntegerटेक्स्ट रेंज का आखिरी ऑफ़सेट.
strikethroughBooleanस्ट्राइकथ्रू सेटिंग.

वापसी का टिकट

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

अनुमति देना

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

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

setText(text)

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

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Replaces the contents of the body with the text, 'New body text.'
const text = body.editAsText().setText('New body text.');

पैरामीटर

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

वापसी का टिकट

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

अनुमति देना

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

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

setTextAlignment(startOffset, endOffsetInclusive, textAlignment)

इससे वर्णों की दी गई रेंज के लिए, टेक्स्ट अलाइनमेंट सेट किया जाता है. अलाइनमेंट के ये टाइप उपलब्ध हैं: DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT, और DocumentApp.TextAlignment.SUPERSCRIPT.

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

पैरामीटर

नामटाइपब्यौरा
startOffsetIntegerवर्ण सीमा का शुरुआती ऑफ़सेट.
endOffsetInclusiveIntegerवर्ण सीमा के आखिर में ऑफ़सेट (शामिल है).
textAlignmentTextAlignmentटेक्स्ट अलाइनमेंट का वह टाइप जिसे लागू करना है.

वापसी का टिकट

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

अनुमति देना

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

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

वापसी का टिकट

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

अनुमति देना

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

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

setUnderline(underline)

इस विकल्प का इस्तेमाल, अंडरलाइन की सेटिंग सेट करने के लिए किया जाता है.

पैरामीटर

नामटाइपब्यौरा
underlineBooleanअंडरलाइन सेटिंग

वापसी का टिकट

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

अनुमति देना

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

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

setUnderline(startOffset, endOffsetInclusive, underline)

इससे, वर्णों की तय की गई रेंज के लिए अंडरलाइन की सेटिंग सेट की जाती है.

// Opens the Docs file by its URL. If you created your script from within a
// Google Docs file, you can use DocumentApp.getActiveDocument() instead.
// TODO(developer): Replace the URL with your own.
const doc = DocumentApp.openByUrl(
    'https://docs.google.com/document/d/DOCUMENT_ID/edit',
);

// Gets the body contents of the tab by its ID.
// TODO(developer): Replace the ID with your own.
const body = doc.getTab('123abc').asDocumentTab().getBody();

// Sets the first 11 characters in the tab's body to underline.
const text = body.editAsText().setUnderline(0, 10, true);

पैरामीटर

नामटाइपब्यौरा
startOffsetIntegerटेक्स्ट रेंज का शुरुआती ऑफ़सेट.
endOffsetInclusiveIntegerटेक्स्ट रेंज का आखिरी ऑफ़सेट.
underlineBooleanअंडरलाइन करने की सेटिंग.

वापसी का टिकट

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

अनुमति देना

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

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