रिच टेक्स्ट वाले क्षेत्र को दिखाने वाला एलिमेंट. 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');
तरीके
| तरीका | रिटर्न टाइप | संक्षिप्त विवरण |
|---|---|---|
append | Text | इस टेक्स्ट रीजन के आखिर में, तय किया गया टेक्स्ट जोड़ता है. |
copy() | Text | यह फ़ंक्शन, मौजूदा एलिमेंट की अलग की गई डीप कॉपी दिखाता है. |
delete | Text | टेक्स्ट की किसी रेंज को मिटाता है. |
edit | Text | बदलाव करने के लिए, मौजूदा एलिमेंट का Text वर्शन मिलता है. |
find | Range | रेगुलर एक्सप्रेशन का इस्तेमाल करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है. |
find | Range | यह फ़ंक्शन, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है. यह खोज, दिए गए खोज नतीजे से शुरू होती है. |
get | Object | यह एलिमेंट के एट्रिब्यूट वापस लाता है. |
get | Object | इससे, तय किए गए वर्ण ऑफ़सेट पर मौजूद एट्रिब्यूट मिलते हैं. |
get | String|null | बैकग्राउंड के रंग की सेटिंग वापस लाता है. |
get | String|null | इससे, तय किए गए वर्ण ऑफ़सेट पर बैकग्राउंड का रंग मिलता है. |
get | String|null | यह फ़ॉन्ट फ़ैमिली की सेटिंग को वापस लाता है. |
get | String|null | इससे, तय किए गए वर्ण ऑफ़सेट पर मौजूद फ़ॉन्ट फ़ैमिली मिलती है. |
get | Number|null | यह कुकी, फ़ॉन्ट के साइज़ की सेटिंग को वापस लाती है. |
get | Number|null | इससे, तय किए गए वर्ण ऑफ़सेट पर फ़ॉन्ट का साइज़ मिलता है. |
get | String|null | फ़ोरग्राउंड के रंग की सेटिंग वापस लाता है. |
get | String|null | इससे, तय किए गए वर्ण ऑफ़सेट पर फ़ोरग्राउंड का रंग मिलता है. |
get | String|null | यह कुकी, लिंक का यूआरएल वापस पाती है. |
get | String|null | इससे, तय किए गए वर्ण ऑफ़सेट पर मौजूद लिंक का यूआरएल मिलता है. |
get | Element|null | यह एलिमेंट के अगले सिबलिंग एलिमेंट को वापस लाता है. |
get | Container | यह एलिमेंट के पैरंट एलिमेंट को वापस लाता है. |
get | Element|null | यह एलिमेंट के पिछले सिबलिंग एलिमेंट को वापस लाता है. |
get | String | यह फ़ंक्शन, एलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर वापस लाता है. |
get | Text | टेक्स्ट अलाइनमेंट की जानकारी मिलती है. |
get | Text | किसी वर्ण के लिए टेक्स्ट अलाइनमेंट की जानकारी मिलती है. |
get | Integer[] | यह फ़ंक्शन, टेक्स्ट इंडेक्स का वह सेट वापस लाता है जो टेक्स्ट फ़ॉर्मैटिंग के अलग-अलग रन की शुरुआत से मेल खाता है. |
get | Element | यह एलिमेंट के Element को वापस लाता है. |
insert | Text | इससे, दिए गए वर्ण ऑफ़सेट पर बताया गया टेक्स्ट डाला जाता है. |
is | Boolean | इससे यह तय होता है कि एलिमेंट, Document के आखिर में है या नहीं. |
is | Boolean|null | इस कुकी का इस्तेमाल, बोल्ड सेटिंग को वापस पाने के लिए किया जाता है. |
is | Boolean|null | इससे, तय किए गए वर्ण ऑफ़सेट पर बोल्ड सेटिंग मिलती है. |
is | Boolean|null | इससे इटैलिक सेटिंग मिलती है. |
is | Boolean|null | इससे, तय किए गए वर्ण ऑफ़सेट पर इटैलिक सेटिंग मिलती है. |
is | Boolean|null | इस कुकी का इस्तेमाल, स्ट्राइकथ्रू सेटिंग को वापस पाने के लिए किया जाता है. |
is | Boolean|null | इससे, दिए गए वर्ण के ऑफ़सेट पर स्ट्राइकथ्रू सेटिंग मिलती है. |
is | Boolean|null | इस कुकी का इस्तेमाल, अंडरलाइन की सेटिंग को वापस पाने के लिए किया जाता है. |
is | Boolean|null | इससे, तय किए गए वर्ण ऑफ़सेट पर अंडरलाइन की सेटिंग मिलती है. |
merge() | Text|null | इस विकल्प का इस्तेमाल करके, एलिमेंट को उसी तरह के पिछले सिबलिंग के साथ मर्ज किया जाता है. |
remove | Text|null | इस फ़ंक्शन का इस्तेमाल करके, एलिमेंट को उसके पैरंट से हटाया जा सकता है. |
replace | Element | रेगुलर एक्सप्रेशन का इस्तेमाल करके, दिए गए टेक्स्ट पैटर्न की सभी जगहों पर, दिए गए रिप्लेसमेंट स्ट्रिंग को बदलता है. |
set | Text | यह फ़ंक्शन, वर्णों की दी गई रेंज पर तय किए गए एट्रिब्यूट लागू करता है. |
set | Text | यह एलिमेंट के एट्रिब्यूट सेट करता है. |
set | Text | इससे, तय की गई वर्ण सीमा के लिए बैकग्राउंड का रंग सेट किया जाता है. |
set | Text | बैकग्राउंड का रंग सेट करता है. |
set | Text | इससे बोल्ड सेटिंग सेट की जाती है. |
set | Text | इससे, वर्णों की चुनी गई रेंज के लिए बोल्ड सेटिंग सेट की जाती है. |
set | Text | इससे तय किए गए वर्णों की रेंज के लिए फ़ॉन्ट फ़ैमिली सेट की जाती है. |
set | Text | इससे फ़ॉन्ट फ़ैमिली सेट की जाती है. |
set | Text | इससे वर्णों की तय की गई रेंज के लिए फ़ॉन्ट का साइज़ सेट किया जाता है. |
set | Text | इससे फ़ॉन्ट का साइज़ सेट किया जाता है. |
set | Text | इससे तय किए गए वर्णों की रेंज के लिए, फ़ोरग्राउंड का रंग सेट किया जाता है. |
set | Text | इससे फ़ोरग्राउंड का रंग सेट किया जाता है. |
set | Text | इससे इटैलिक सेटिंग सेट की जाती है. |
set | Text | इससे, वर्णों की तय की गई रेंज के लिए इटैलिक सेटिंग सेट की जाती है. |
set | Text | यह विकल्प, वर्णों की तय सीमा के लिए लिंक यूआरएल सेट करता है. |
set | Text | यह लिंक का यूआरएल सेट करता है. |
set | Text | इस विकल्प का इस्तेमाल करके, स्ट्राइकथ्रू सेटिंग सेट की जाती है. |
set | Text | इससे, वर्णों की तय की गई रेंज के लिए स्ट्राइकथ्रू सेटिंग सेट की जाती है. |
set | Text | इस विकल्प से, टेक्स्ट कॉन्टेंट सेट किया जाता है. |
set | Text | इससे वर्णों की दी गई रेंज के लिए, टेक्स्ट अलाइनमेंट सेट किया जाता है. |
set | Text | इससे टेक्स्ट अलाइनमेंट सेट किया जाता है. |
set | Text | इस विकल्प का इस्तेमाल, अंडरलाइन की सेटिंग सेट करने के लिए किया जाता है. |
set | 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');
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
text | String | जोड़ा जाने वाला टेक्स्ट. |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
start | Integer | मिटाए जाने वाले पहले वर्ण का ऑफ़सेट. |
end | Integer | मिटाए जाने वाले आखिरी वर्ण का ऑफ़सेट. |
वापसी का टिकट
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 रेगुलर एक्सप्रेशन की कुछ सुविधाओं का पूरी तरह से इस्तेमाल नहीं किया जा सकता. जैसे, कैप्चर ग्रुप और मोड मॉडिफ़ायर.
दिए गए रेगुलर एक्सप्रेशन पैटर्न का मिलान, मौजूदा एलिमेंट में मौजूद हर टेक्स्ट ब्लॉक से अलग-अलग किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
search | String | खोजने के लिए पैटर्न |
वापसी का टिकट
RangeElement|null — खोज के नतीजे में खोजे गए टेक्स्ट की पोज़िशन दिखाता है. अगर कोई मैच नहीं मिलता है, तो यह शून्य होता है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
findText(searchPattern, from)
यह फ़ंक्शन, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है. यह खोज, दिए गए खोज नतीजे से शुरू होती है.
JavaScript रेगुलर एक्सप्रेशन की कुछ सुविधाओं का पूरी तरह से इस्तेमाल नहीं किया जा सकता. जैसे, कैप्चर ग्रुप और मोड मॉडिफ़ायर.
दिए गए रेगुलर एक्सप्रेशन पैटर्न का मिलान, मौजूदा एलिमेंट में मौजूद हर टेक्स्ट ब्लॉक से अलग-अलग किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
search | String | खोजने के लिए पैटर्न |
from | Range | खोज के नतीजे में मौजूद वह आइटम जिससे खोज करनी है |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
offset | Integer | वर्ण ऑफ़सेट. |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
offset | Integer | वर्ण ऑफ़सेट. |
वापसी का टिकट
String|null — बैकग्राउंड का रंग, जिसे सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया है.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getFontFamily()
यह फ़ॉन्ट फ़ैमिली की सेटिंग को वापस लाता है. नाम, Docs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू में से किसी भी फ़ॉन्ट का हो सकता है. यह केस-सेंसिटिव होता है. getFontFamily() और setFontFamily(fontFamilyName) तरीके अब फ़ॉन्ट के लिए स्ट्रिंग नामों का इस्तेमाल करते हैं. ये enum का इस्तेमाल नहीं करते. हालांकि, इस enum को अब इस्तेमाल नहीं किया जा सकता, लेकिन यह पुरानी स्क्रिप्ट के साथ काम करता रहेगा.FontFamily
वापसी का टिकट
String|null — फ़ॉन्ट फ़ैमिली या null. ऐसा तब होता है, जब एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हों
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getFontFamily(offset)
इससे, तय किए गए वर्ण ऑफ़सेट पर मौजूद फ़ॉन्ट फ़ैमिली मिलती है. नाम, Docs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू में से कोई भी फ़ॉन्ट हो सकता है. साथ ही, यह केस-सेंसिटिव होता है. अब getFontFamily() और setFontFamily(fontFamilyName) तरीकों में, फ़ॉन्ट के लिए enum के बजाय स्ट्रिंग नामों का इस्तेमाल किया जाता है. हालांकि, इस enum को अब इस्तेमाल नहीं किया जा सकता, लेकिन यह पुरानी स्क्रिप्ट के साथ काम करता रहेगा.
FontFamily
// 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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
offset | Integer | वर्ण ऑफ़सेट. |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
offset | Integer | वर्ण ऑफ़सेट. |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
offset | Integer | वर्ण ऑफ़सेट. |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
offset | Integer | वर्ण ऑफ़सेट. |
वापसी का टिकट
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());
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
offset | Integer | वर्ण का ऑफ़सेट. |
वापसी का टिकट
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');
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
offset | Integer | वर्ण ऑफ़सेट, जहां टेक्स्ट डाला जाना है. |
text | String | वह टेक्स्ट जिसे शामिल करना है. |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
offset | Integer | वर्ण ऑफ़सेट. |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
offset | Integer | वर्ण ऑफ़सेट. |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
offset | Integer | वर्ण ऑफ़सेट. |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
offset | Integer | वर्ण ऑफ़सेट. |
वापसी का टिकट
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');
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
search | String | खोज के लिए रेगुलर एक्सप्रेशन पैटर्न |
replacement | String | बदलाव के तौर पर इस्तेमाल किया जाने वाला टेक्स्ट |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
start | Integer | टेक्स्ट रेंज का शुरुआती ऑफ़सेट. |
end | Integer | टेक्स्ट रेंज का आखिरी ऑफ़सेट. |
attributes | Object | एलिमेंट के एट्रिब्यूट. |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
attributes | Object | एलिमेंट के एट्रिब्यूट. |
वापसी का टिकट
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');
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
start | Integer | टेक्स्ट रेंज का शुरुआती ऑफ़सेट. |
end | Integer | टेक्स्ट रेंज का आखिरी ऑफ़सेट. |
color | String | बैकग्राउंड का रंग, जिसे सीएसएस नोटेशन (जैसे, '#ffffff') में फ़ॉर्मैट किया गया है. |
वापसी का टिकट
Text — मौजूदा एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setBackgroundColor(color)
बैकग्राउंड का रंग सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
color | String | बैकग्राउंड का रंग, सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setBold(bold)
इससे बोल्ड सेटिंग सेट की जाती है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
bold | Boolean | बोल्ड सेटिंग |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
start | Integer | टेक्स्ट रेंज का शुरुआती ऑफ़सेट. |
end | Integer | टेक्स्ट रेंज का आखिरी ऑफ़सेट. |
bold | Boolean | बोल्ड सेटिंग. |
वापसी का टिकट
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) तरीके, अब फ़ॉन्ट के लिए enum के बजाय स्ट्रिंग नामों का इस्तेमाल करते हैं. हालांकि, इस enum को अब इस्तेमाल नहीं किया जा सकता, लेकिन यह पुरानी स्क्रिप्ट के साथ काम करता रहेगा.
FontFamily
// 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');
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
start | Integer | टेक्स्ट रेंज का शुरुआती ऑफ़सेट. |
end | Integer | टेक्स्ट रेंज का आखिरी ऑफ़सेट. |
font | String | Docs या 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) तरीके, अब फ़ॉन्ट के लिए enum के बजाय स्ट्रिंग नामों का इस्तेमाल करते हैं. हालांकि, इस enum को अब इस्तेमाल नहीं किया जा सकता, लेकिन यह पुरानी स्क्रिप्ट के साथ काम करता रहेगा.FontFamily
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
font | String | 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/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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
start | Integer | टेक्स्ट रेंज का शुरुआती ऑफ़सेट. |
end | Integer | टेक्स्ट रेंज का आखिरी ऑफ़सेट. |
size | Number | फ़ॉन्ट का साइज़. |
वापसी का टिकट
Text — मौजूदा एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setFontSize(size)
इससे फ़ॉन्ट का साइज़ सेट किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
size | Number | फ़ॉन्ट का साइज़ |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
start | Integer | टेक्स्ट रेंज का शुरुआती ऑफ़सेट. |
end | Integer | टेक्स्ट रेंज का आखिरी ऑफ़सेट. |
color | String | फ़ोरग्राउंड का रंग, सीएसएस नोटेशन (जैसे, '#ffffff') में फ़ॉर्मैट किया गया है. |
वापसी का टिकट
Text — मौजूदा एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setForegroundColor(color)
इससे फ़ोरग्राउंड का रंग सेट किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
color | String | फ़ोरग्राउंड का रंग, जिसे सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया हो |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setItalic(italic)
इससे इटैलिक सेटिंग सेट की जाती है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
italic | Boolean | इटैलिक सेटिंग |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
start | Integer | टेक्स्ट रेंज का शुरुआती ऑफ़सेट. |
end | Integer | टेक्स्ट रेंज का आखिरी ऑफ़सेट. |
italic | Boolean | इटैलिक सेटिंग. |
वापसी का टिकट
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');
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
start | Integer | टेक्स्ट रेंज का शुरुआती ऑफ़सेट. |
end | Integer | टेक्स्ट रेंज का आखिरी ऑफ़सेट. |
url | String | लिंक का यूआरएल. |
वापसी का टिकट
Text — मौजूदा एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setLinkUrl(url)
यह लिंक का यूआरएल सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
url | String | लिंक का यूआरएल |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setStrikethrough(strikethrough)
इस विकल्प का इस्तेमाल करके, स्ट्राइकथ्रू सेटिंग सेट की जाती है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
strikethrough | Boolean | स्ट्राइकथ्रू सेटिंग |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
start | Integer | टेक्स्ट रेंज का शुरुआती ऑफ़सेट. |
end | Integer | टेक्स्ट रेंज का आखिरी ऑफ़सेट. |
strikethrough | Boolean | स्ट्राइकथ्रू सेटिंग. |
वापसी का टिकट
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.');
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
text | String | नया टेक्स्ट कॉन्टेंट. |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
start | Integer | वर्ण सीमा का शुरुआती ऑफ़सेट. |
end | Integer | वर्ण सीमा के आखिर में ऑफ़सेट (शामिल है). |
text | Text | टेक्स्ट अलाइनमेंट का वह टाइप जिसे लागू करना है. |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
text | Text | टेक्स्ट अलाइनमेंट का टाइप |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setUnderline(underline)
इस विकल्प का इस्तेमाल, अंडरलाइन की सेटिंग सेट करने के लिए किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
underline | Boolean | अंडरलाइन सेटिंग |
वापसी का टिकट
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);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
start | Integer | टेक्स्ट रेंज का शुरुआती ऑफ़सेट. |
end | Integer | टेक्स्ट रेंज का आखिरी ऑफ़सेट. |
underline | Boolean | अंडरलाइन की सेटिंग. |
वापसी का टिकट
Text — मौजूदा एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents