रिच टेक्स्ट वाले क्षेत्र को दिखाने वाला एलिमेंट. Document में मौजूद सभी टेक्स्ट, Text एलिमेंट में शामिल होते हैं.
Text एलिमेंट को Equation, Equation, List या 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 | इससे, वर्णों की तय की गई रेंज के लिए अंडरलाइन की सेटिंग सेट की जाती है. |
ज़्यादा जानकारी वाला दस्तावेज़
append Text(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
delete Text(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
edit As Text()
बदलाव करने के लिए, मौजूदा एलिमेंट का Text वर्शन मिलता है.
रिच टेक्स्ट के तौर पर एलिमेंट के कॉन्टेंट में बदलाव करने के लिए, edit का इस्तेमाल करें. edit मोड में, टेक्स्ट के अलावा अन्य एलिमेंट (जैसे कि Inline और Horizontal) को अनदेखा कर दिया जाता है.
मिटाए गए टेक्स्ट रेंज में पूरी तरह से शामिल चाइल्ड एलिमेंट को एलिमेंट से हटा दिया जाता है.
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 — मौजूदा एलिमेंट का टेक्स्ट वर्शन
find Text(searchPattern)
रेगुलर एक्सप्रेशन का इस्तेमाल करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है.
JavaScript रेगुलर एक्सप्रेशन की कुछ सुविधाओं का पूरी तरह से इस्तेमाल नहीं किया जा सकता. जैसे, कैप्चर ग्रुप और मोड मॉडिफ़ायर.
दिए गए रेगुलर एक्सप्रेशन पैटर्न का मिलान, मौजूदा एलिमेंट में मौजूद हर टेक्स्ट ब्लॉक से अलग-अलग किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
search | String | खोजने के लिए पैटर्न |
वापसी का टिकट
Range — खोज के नतीजे में खोजे गए टेक्स्ट की पोज़िशन दिखाता है. अगर कोई मैच नहीं मिलता है, तो यह शून्य होता है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
find Text(searchPattern, from)
यह फ़ंक्शन, दिए गए खोज नतीजे से शुरू करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है.
JavaScript रेगुलर एक्सप्रेशन की कुछ सुविधाओं का पूरी तरह से इस्तेमाल नहीं किया जा सकता. जैसे, कैप्चर ग्रुप और मोड मॉडिफ़ायर.
दिए गए रेगुलर एक्सप्रेशन पैटर्न का मिलान, मौजूदा एलिमेंट में मौजूद हर टेक्स्ट ब्लॉक से अलग-अलग किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
search | String | खोजने के लिए पैटर्न |
from | Range | खोज के नतीजे में मौजूद वह आइटम जिससे खोज करनी है |
वापसी का टिकट
Range — खोज के नतीजे में, खोजे गए टेक्स्ट की अगली पोज़िशन दिखाता है. अगर कोई मैच नहीं मिलता है, तो यह शून्य होता है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Attributes()
यह एलिमेंट के एट्रिब्यूट वापस लाता है.
नतीजा एक ऐसा ऑब्जेक्ट होता है जिसमें हर मान्य एलिमेंट एट्रिब्यूट के लिए एक प्रॉपर्टी होती है. इसमें हर प्रॉपर्टी का नाम, Document इन्यूमरेशन में मौजूद किसी आइटम से मेल खाता है.
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
get Attributes(offset)
इससे, तय किए गए वर्ण ऑफ़सेट पर मौजूद एट्रिब्यूट मिलते हैं.
नतीजे के तौर पर एक ऑब्जेक्ट मिलता है. इसमें हर मान्य टेक्स्ट एट्रिब्यूट के लिए एक प्रॉपर्टी होती है. हर प्रॉपर्टी का नाम, Document इन्यूमरेशन में मौजूद किसी आइटम से मेल खाता है.
// 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
get Background Color()
बैकग्राउंड के रंग की सेटिंग वापस लाता है.
वापसी का टिकट
String|null — बैकग्राउंड का रंग, सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया है. अगर एलिमेंट में इस एट्रिब्यूट के लिए एक से ज़्यादा वैल्यू शामिल हैं, तो यह null होगा
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Background Color(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
get Font Family()
यह फ़ॉन्ट फ़ैमिली की सेटिंग को वापस लाता है. नाम, Docs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू में से किसी भी फ़ॉन्ट का हो सकता है. यह केस-सेंसिटिव होता है. get और set तरीके अब enum के बजाय, फ़ॉन्ट के लिए स्ट्रिंग नामों का इस्तेमाल करते हैं. हालांकि, इस enum को अब इस्तेमाल नहीं किया जा सकता, लेकिन यह पुरानी स्क्रिप्ट के साथ काम करता रहेगा.Font
वापसी का टिकट
String|null — फ़ॉन्ट फ़ैमिली या अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो null
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Font Family(offset)
इससे, तय किए गए वर्ण ऑफ़सेट पर मौजूद फ़ॉन्ट फ़ैमिली मिलती है. नाम, Docs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू में से किसी भी फ़ॉन्ट का हो सकता है. साथ ही, यह केस-सेंसिटिव होता है. अब get और set तरीकों में, फ़ॉन्ट के लिए enum के बजाय स्ट्रिंग नामों का इस्तेमाल किया जाता है. हालांकि, इस enum को अब इस्तेमाल नहीं किया जा सकता, लेकिन यह पुरानी स्क्रिप्ट के साथ काम करता रहेगा.
Font
// 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
get Font Size()
यह कुकी, फ़ॉन्ट के साइज़ की सेटिंग को वापस लाती है.
वापसी का टिकट
Number|null — फ़ॉन्ट का साइज़ या अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो शून्य
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Font Size(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
get Foreground Color()
फ़ोरग्राउंड के रंग की सेटिंग वापस लाता है.
वापसी का टिकट
String|null — फ़ोरग्राउंड का रंग, सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया है. अगर एलिमेंट में इस एट्रिब्यूट के लिए एक से ज़्यादा वैल्यू शामिल हैं, तो यह null होगा
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Foreground Color(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
get Link Url()
यह कुकी, लिंक का यूआरएल वापस पाती है.
वापसी का टिकट
String|null — लिंक यूआरएल या अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो null
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Link Url(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
get Next Sibling()
यह एलिमेंट के अगले सिबलिंग एलिमेंट को वापस लाता है.
अगले सिबलिंग का पैरंट वही होता है जो मौजूदा एलिमेंट का होता है. साथ ही, यह मौजूदा एलिमेंट के बाद आता है.
वापसी का टिकट
Element|null — अगला सिबलिंग एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Parent()
यह एलिमेंट के पैरंट एलिमेंट को वापस लाता है.
पैरंट एलिमेंट में मौजूदा एलिमेंट शामिल है.
वापसी का टिकट
Container — पैरंट एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Previous Sibling()
यह एलिमेंट के पिछले समरूप एलिमेंट को वापस लाता है.
पिछला सिबलिंग, मौजूदा एलिमेंट से पहले आता है और उसका पैरंट एलिमेंट भी मौजूदा एलिमेंट जैसा ही होता है.
वापसी का टिकट
Element|null — पिछला सिबलिंग एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text()
यह फ़ंक्शन, एलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर वापस लाता है.
वापसी का टिकट
String — एलिमेंट का कॉन्टेंट, टेक्स्ट स्ट्रिंग के तौर पर
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text Alignment()
टेक्स्ट अलाइनमेंट की जानकारी मिलती है. अलाइनमेंट के लिए ये विकल्प उपलब्ध हैं: Document, Document, और Document.
वापसी का टिकट
Text — टेक्स्ट अलाइनमेंट का टाइप या null अगर टेक्स्ट में कई तरह के टेक्स्ट अलाइनमेंट शामिल हैं या टेक्स्ट अलाइनमेंट कभी सेट नहीं किया गया है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text Alignment(offset)
किसी वर्ण के लिए टेक्स्ट अलाइनमेंट की जानकारी मिलती है. अलाइनमेंट के लिए ये विकल्प उपलब्ध हैं: Document, Document, और Document.
// 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 | वर्ण का ऑफ़सेट. |
वापसी का टिकट
Text — टेक्स्ट अलाइनमेंट का टाइप या null, अगर टेक्स्ट अलाइनमेंट कभी सेट नहीं किया गया है.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
get Text Attribute Indices()
यह फ़ंक्शन, टेक्स्ट इंडेक्स का वह सेट वापस लाता है जो टेक्स्ट फ़ॉर्मैटिंग के अलग-अलग रन की शुरुआत से मेल खाता है.
// 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
get Type()
यह एलिमेंट के Element को वापस लाता है.
किसी एलिमेंट के टाइप का पता लगाने के लिए, get का इस्तेमाल करें.
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.'); }
वापसी का टिकट
Element — एलिमेंट का टाइप.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insert Text(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
is At Document End()
इससे यह तय होता है कि एलिमेंट, Document के आखिर में है या नहीं.
वापसी का टिकट
Boolean — इससे पता चलता है कि एलिमेंट टैब के आखिर में है या नहीं.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Bold()
बोल्ड सेटिंग को वापस लाता है.
वापसी का टिकट
Boolean|null — टेक्स्ट बोल्ड है या नहीं. अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो वैल्यू शून्य होगी
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Bold(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
is Italic()
इटैलिक सेटिंग वापस लाता है.
वापसी का टिकट
Boolean|null — टेक्स्ट इटैलिक है या नहीं. अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो वैल्यू शून्य होगी
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Italic(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
is Strikethrough()
इस तरीके से, स्ट्राइकथ्रू सेटिंग को वापस पाया जाता है.
वापसी का टिकट
Boolean|null — टेक्स्ट पर काटा गया निशान है या नहीं. अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो वैल्यू शून्य होगी
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Strikethrough(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
is Underline()
इस कुकी का इस्तेमाल, अंडरलाइन की सेटिंग को वापस पाने के लिए किया जाता है.
वापसी का टिकट
Boolean|null — टेक्स्ट के नीचे लाइन है या नहीं. अगर एलिमेंट में इस एट्रिब्यूट के लिए एक से ज़्यादा वैल्यू शामिल हैं, तो वैल्यू शून्य होगी
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
is Underline(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()
इस विकल्प का इस्तेमाल करके, एलिमेंट को उसी तरह के पिछले एलिमेंट के साथ मर्ज किया जाता है.
सिर्फ़ एक ही Element के एलिमेंट मर्ज किए जा सकते हैं. मौजूदा एलिमेंट में मौजूद सभी चाइल्ड एलिमेंट को, पहले वाले सिबलिंग एलिमेंट में ले जाया जाता है.
मौजूदा एलिमेंट को दस्तावेज़ से हटा दिया जाता है.
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
remove From Parent()
इस तरीके का इस्तेमाल करके, एलिमेंट को उसके पैरंट से हटाया जा सकता है.
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
replace Text(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
set Attributes(startOffset, endOffsetInclusive, attributes)
यह फ़ंक्शन, वर्णों की दी गई रेंज पर तय किए गए एट्रिब्यूट लागू करता है.
तय किया गया एट्रिब्यूट पैरामीटर एक ऑब्जेक्ट होना चाहिए. इसमें हर प्रॉपर्टी का नाम, Document इन्यूमरेशन में मौजूद एक आइटम होता है. साथ ही, हर प्रॉपर्टी की वैल्यू, लागू की जाने वाली नई वैल्यू होती है.
// 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
set Attributes(attributes)
यह एलिमेंट के एट्रिब्यूट सेट करता है.
तय किया गया एट्रिब्यूट पैरामीटर एक ऑब्जेक्ट होना चाहिए. इसमें हर प्रॉपर्टी का नाम, Document इन्यूमरेशन में मौजूद एक आइटम होता है. साथ ही, हर प्रॉपर्टी की वैल्यू, लागू की जाने वाली नई वैल्यू होती है.
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
set Background Color(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
set Background Color(color)
बैकग्राउंड का रंग सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
color | String | बैकग्राउंड का रंग, सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Bold(bold)
इससे बोल्ड सेटिंग सेट की जाती है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
bold | Boolean | बोल्ड सेटिंग |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Bold(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
set Font Family(startOffset, endOffsetInclusive, fontFamilyName)
इससे तय किए गए वर्णों की रेंज के लिए फ़ॉन्ट फ़ैमिली सेट की जाती है. नाम, Docs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू में से कोई भी फ़ॉन्ट हो सकता है. यह केस-सेंसिटिव (बड़े और छोटे अक्षरों में अंतर) होता है.
जिन फ़ॉन्ट के नामों की पहचान नहीं की जा सकेगी वे Arial के तौर पर रेंडर होंगे. get और set तरीके, अब enum के बजाय फ़ॉन्ट के लिए स्ट्रिंग नामों का इस्तेमाल करते हैं. हालांकि, इस enum को अब इस्तेमाल नहीं किया जा सकता, लेकिन यह पुरानी स्क्रिप्ट के साथ काम करता रहेगा.
Font
// 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
set Font Family(fontFamilyName)
इससे फ़ॉन्ट फ़ैमिली सेट की जाती है. नाम, Docs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू में से किसी भी फ़ॉन्ट का हो सकता है. यह केस-सेंसिटिव होता है. जिन फ़ॉन्ट के नामों की पहचान नहीं हो पाएगी वे Arial के तौर पर रेंडर होंगे. get और set तरीके, अब enum के बजाय फ़ॉन्ट के लिए स्ट्रिंग नामों का इस्तेमाल करते हैं. हालांकि, इस enum को अब इस्तेमाल नहीं किया जा सकता, लेकिन यह पुरानी स्क्रिप्ट के साथ काम करता रहेगा.Font
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
font | String | Docs या Google Fonts में मौजूद फ़ॉन्ट मेन्यू से, फ़ॉन्ट फ़ैमिली का नाम |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Font Size(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
set Font Size(size)
इससे फ़ॉन्ट का साइज़ सेट किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
size | Number | फ़ॉन्ट का साइज़ |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Foreground Color(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
set Foreground Color(color)
इससे फ़ोरग्राउंड का रंग सेट किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
color | String | फ़ोरग्राउंड का रंग, जिसे सीएसएस नोटेशन (जैसे कि '#ffffff') में फ़ॉर्मैट किया गया हो |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Italic(italic)
इससे इटैलिक सेटिंग सेट की जाती है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
italic | Boolean | इटैलिक सेटिंग |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Italic(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
set Link Url(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
set Link Url(url)
यह कुकी, लिंक किए गए यूआरएल को सेट करती है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
url | String | लिंक का यूआरएल |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Strikethrough(strikethrough)
इस विकल्प का इस्तेमाल करके, स्ट्राइकथ्रू सेटिंग सेट की जाती है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
strikethrough | Boolean | स्ट्राइकथ्रू सेटिंग |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Strikethrough(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
set Text(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
set Text Alignment(startOffset, endOffsetInclusive, textAlignment)
इससे वर्णों की दी गई रेंज के लिए, टेक्स्ट अलाइनमेंट सेट किया जाता है. अलाइनमेंट के ये टाइप उपलब्ध हैं:
Document, Document, और
Document.
// 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
set Text Alignment(textAlignment)
इससे टेक्स्ट अलाइनमेंट सेट किया जाता है. अलाइनमेंट के लिए ये विकल्प उपलब्ध हैं: Document, Document, और Document.
// 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
set Underline(underline)
इस विकल्प का इस्तेमाल, अंडरलाइन की सेटिंग सेट करने के लिए किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
underline | Boolean | अंडरलाइन सेटिंग |
वापसी का टिकट
Text — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या एक से ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
set Underline(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