Class Text

टेक्स्ट

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

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

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

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

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

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

तरीके

तरीकारिटर्न टाइपसंक्षिप्त विवरण
appendText(text)Textबताए गए टेक्स्ट को इस टेक्स्ट क्षेत्र के आखिर में जोड़ता है.
copy()Textमौजूदा एलिमेंट की अलग, गहरी कॉपी दिखाता है.
deleteText(startOffset, endOffsetInclusive)Textलेख की श्रेणी हटाता है.
editAsText()Textबदलाव करने के लिए, मौजूदा एलिमेंट के Text वर्शन को हासिल करता है.
findText(searchPattern)RangeElementरेगुलर एक्सप्रेशन का इस्तेमाल करके, तय टेक्स्ट पैटर्न के लिए एलिमेंट के कॉन्टेंट की खोज करता है.
findText(searchPattern, from)RangeElementदिए गए खोज नतीजे से शुरू करते हुए, तय टेक्स्ट पैटर्न के लिए एलिमेंट के कॉन्टेंट की खोज करता है.
getAttributes()Objectएलिमेंट के एट्रिब्यूट वापस लाता है.
getAttributes(offset)Objectबताए गए वर्ण ऑफ़सेट पर एट्रिब्यूट वापस लाता है.
getBackgroundColor()Stringबैकग्राउंड की कलर सेटिंग वापस लाता है.
getBackgroundColor(offset)Stringबताए गए वर्ण ऑफ़सेट पर बैकग्राउंड का रंग वापस लाता है.
getFontFamily()Stringफ़ॉन्ट फ़ैमिली की सेटिंग को वापस लाता है.
getFontFamily(offset)Stringतय किए गए वर्ण ऑफ़सेट पर फ़ॉन्ट फ़ैमिली को फिर से लाता है.
getFontSize()Numberफ़ॉन्ट आकार सेटिंग फिर से लाता है.
getFontSize(offset)Numberतय वर्ण ऑफ़सेट पर फ़ॉन्ट साइज़ फिर से हासिल करता है.
getForegroundColor()Stringफ़ोरग्राउंड की कलर सेटिंग वापस लाता है.
getForegroundColor(offset)Stringबताए गए वर्ण ऑफ़सेट पर फ़ोरग्राउंड का रंग वापस लाता है.
getLinkUrl()Stringलिंक यूआरएल वापस लाता है.
getLinkUrl(offset)Stringबताए गए वर्ण ऑफ़सेट पर लिंक यूआरएल वापस लाता है.
getNextSibling()Elementएलिमेंट के अगले सिबलिंग एलिमेंट को वापस लाता है.
getParent()ContainerElementएलिमेंट के पैरंट एलिमेंट को वापस लाता है.
getPreviousSibling()Elementएलिमेंट के पिछले सिबलिंग एलिमेंट को वापस लाता है.
getText()Stringएलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर फ़ेच करता है.
getTextAlignment()TextAlignmentटेक्स्ट अलाइनमेंट की जानकारी हासिल करता है.
getTextAlignment(offset)TextAlignmentकिसी एक वर्ण के लिए टेक्स्ट अलाइनमेंट लेता है.
getTextAttributeIndices()Integer[]अलग-अलग टेक्स्ट फ़ॉर्मैटिंग के शुरू होने से जुड़े टेक्स्ट के इंडेक्स के सेट को हासिल करता है.
getType()ElementTypeElementType के एलिमेंट को वापस लाता है.
insertText(offset, text)Textदिए गए वर्ण ऑफ़सेट पर बताया गया लेख डालता है.
isAtDocumentEnd()Booleanयह तय करता है कि एलिमेंट, Document के आखिर में है या नहीं.
isBold()Booleanबोल्ड सेटिंग वापस लाता है.
isBold(offset)Booleanबताए गए वर्ण ऑफ़सेट पर बोल्ड सेटिंग वापस लाता है.
isItalic()Booleanइटैलिक सेटिंग वापस लाता है.
isItalic(offset)Booleanतय किए गए वर्ण ऑफ़सेट पर इटैलिक सेटिंग वापस लाता है.
isStrikethrough()Booleanस्ट्राइकथ्रू सेटिंग वापस लाता है.
isStrikethrough(offset)Booleanतय वर्ण ऑफ़सेट पर स्ट्राइकथ्रू सेटिंग वापस लाता है.
isUnderline()Booleanअंडरलाइन सेटिंग फिर से लाता है.
isUnderline(offset)Booleanबताए गए वर्ण ऑफ़सेट पर अंडरलाइन सेटिंग वापस लाता है.
merge()Textएलिमेंट को, इसी तरह के दूसरे सिबलिंग के साथ मर्ज कर देता है.
removeFromParent()Textएलिमेंट को उसके पैरंट फ़ोल्डर से हटाता है.
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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

// Adds the text, 'Sample body text,' to the end of the document 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/abc123456/edit');

// Gets the document body.
const body = doc.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 को अनदेखा करता है.

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

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

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

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

रिटर्न टिकट

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


findText(searchPattern)

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

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

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

पैरामीटर

नामटाइपजानकारी
searchPatternStringखोजने का पैटर्न

रिटर्न टिकट

RangeElement — खोज के नतीजे में दिखने वाले टेक्स्ट की जगह दिखाने वाला खोज नतीजा या मेल न खाने पर शून्य

अनुमति देना

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

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

findText(searchPattern, from)

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

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

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

पैरामीटर

नामटाइपजानकारी
searchPatternStringखोजने का पैटर्न
fromRangeElementजिस खोज नतीजे से खोज करनी है

रिटर्न टिकट

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

अनुमति देना

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

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

getAttributes()

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

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

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

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

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

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

रिटर्न टिकट

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/abc123456/edit');

// Gets the document body.
const body = doc.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 document 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 — बैकग्राउंड का रंग, सीएसएस नोटेशन (जैसे '#ffffff') में फ़ॉर्मैट किया जाता है या शून्य होता है. ऐसा तब होता है, जब एलिमेंट में इस एट्रिब्यूट के लिए एक से ज़्यादा वैल्यू हों

अनुमति देना

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

  • 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/abc123456');

// Gets the document body.
const body = doc.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 — बैकग्राउंड का रंग, सीएसएस नोटेशन (जैसे कि '#ffffff') के फ़ॉर्मैट में.

अनुमति देना

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

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

getFontFamily()

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

रिटर्न टिकट

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

अनुमति देना

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

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

getFontFamily(offset)

तय किए गए वर्ण ऑफ़सेट पर फ़ॉन्ट फ़ैमिली को फिर से लाता है. यह नाम, Docs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू में मौजूद किसी भी फ़ॉन्ट में हो सकता है. साथ ही, वह केस-सेंसिटिव (बड़े और छोटे अक्षरों में अंतर) भी होता है. getFontFamily() और setFontFamily(fontFamilyName) वाले तरीके अब FontFamily 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/abc123456/edit');

// Gets the document body.
const body = doc.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 document body.
const fontFamily = text.getFontFamily(15);

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

पैरामीटर

नामटाइपजानकारी
offsetIntegerवर्ण ऑफ़सेट.

रिटर्न टिकट

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

अनुमति देना

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

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

getFontSize()

फ़ॉन्ट आकार सेटिंग फिर से लाता है.

रिटर्न टिकट

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

अनुमति देना

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

  • 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/abc123456/edit');

// Gets the document body.
const body = doc.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 — फ़ॉन्ट का साइज़.

अनुमति देना

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

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

getForegroundColor()

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

रिटर्न टिकट

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

अनुमति देना

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

  • 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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

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

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

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

पैरामीटर

नामटाइपजानकारी
offsetIntegerवर्ण ऑफ़सेट.

रिटर्न टिकट

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

अनुमति देना

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

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

getLinkUrl()

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

रिटर्न टिकट

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

अनुमति देना

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

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

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/abc123456/edit');

// Gets the document body.
const body = doc.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 — लिंक का यूआरएल.

अनुमति देना

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

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

getNextSibling()

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

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

रिटर्न टिकट

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

अनुमति देना

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

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

getParent()

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

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

रिटर्न टिकट

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

अनुमति देना

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

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

getPreviousSibling()

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

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

रिटर्न टिकट

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

अनुमति देना

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

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

getText()

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

रिटर्न टिकट

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

अनुमति देना

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

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

getTextAlignment()

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

रिटर्न टिकट

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

अनुमति देना

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

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

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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

// Sets the text alignment of the document 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.

अनुमति देना

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

  • 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/abc123456/edit');

// Gets the document body.
const body = doc.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() का इस्तेमाल करें.

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

// Obtain the first element in the document body.

var firstChild = body.getChild(0);

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

रिटर्न टिकट

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/abc123456/edit');

// Gets the document body.
const body = doc.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 — अगर एलिमेंट में इस एट्रिब्यूट के लिए एक से ज़्यादा वैल्यू हैं, तो टेक्स्ट बोल्ड है या शून्य है

अनुमति देना

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

  • 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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

// Bolds the first 4 characters in the document 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 — बोल्ड सेटिंग.

अनुमति देना

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

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

isItalic()

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

रिटर्न टिकट

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

अनुमति देना

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

  • 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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

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

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

पैरामीटर

नामटाइपजानकारी
offsetIntegerवर्ण ऑफ़सेट.

रिटर्न टिकट

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

अनुमति देना

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

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

isStrikethrough()

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

रिटर्न टिकट

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

अनुमति देना

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

  • 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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

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

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

पैरामीटर

नामटाइपजानकारी
offsetIntegerवर्ण ऑफ़सेट.

रिटर्न टिकट

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

अनुमति देना

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

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

isUnderline()

अंडरलाइन सेटिंग फिर से लाता है.

रिटर्न टिकट

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

अनुमति देना

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

  • 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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

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

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

पैरामीटर

नामटाइपजानकारी
offsetIntegerवर्ण ऑफ़सेट.

रिटर्न टिकट

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

अनुमति देना

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

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

merge()

एलिमेंट को, इसी तरह के दूसरे सिबलिंग के साथ मर्ज कर देता है.

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

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

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

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

रिटर्न टिकट

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

अनुमति देना

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

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

removeFromParent()

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

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

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

रिटर्न टिकट

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

अनुमति देना

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

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

replaceText(searchPattern, replacement)

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

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

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

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

var body = DocumentApp.getActiveDocument().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/abc123456/edit');

// Gets the document body and edits as text.
const body = doc.getBody().editAsText();

// 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 document 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 की गिनती में एक आइटम हो और हर प्रॉपर्टी की वैल्यू लागू की गई हो.

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

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

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

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

पैरामीटर

नामटाइपजानकारी
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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

// Sets the background color of the first 3 characters in the
// document 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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

// Sets the first 11 characters in the document 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)

तय वर्ण सीमा के लिए फ़ॉन्ट फ़ैमिली सेट करता है. नाम, दस्तावेज़ या Google फ़ॉन्ट में फ़ॉन्ट मेन्यू से कोई भी फ़ॉन्ट हो सकता है और केस-सेंसिटिव (बड़े और छोटे अक्षरों में अंतर) होता है. बिना पहचान वाले फ़ॉन्ट नाम एरियल के रूप में रेंडर होंगे. getFontFamily(offset) और setFontFamily(fontFamilyName) दोनों ही तरीके, अब FontFamily 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/abc123456/edit');

// Gets body of the document.
const body = doc.getBody();

// Sets the font of the first 4 characters in the document 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)

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

पैरामीटर

नामटाइपजानकारी
fontFamilyNameStringफ़ॉन्ट फ़ैमिली का नाम, Docs या 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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

// Sets the size of the first 11 characters in the document 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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

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

// Gets the foreground color for the second character in the document 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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

// Sets the first 11 characters in the document 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/abc123456/edit');

// Gets the document body.
const body = doc.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लिंक url

रिटर्न टिकट

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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

// Sets the first 11 characters in the document 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/abc123456/edit');

// Gets the document body.
const body = doc.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 be superscript.
var text = DocumentApp.getActiveDocument().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 be superscript.
var text = DocumentApp.getActiveDocument().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/abc123456/edit');

// Gets the document body.
const body = doc.getBody();

// Sets the first 11 characters in the document 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