रिच टेक्स्ट वाले क्षेत्र को दिखाने वाला एलिमेंट. 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 | बैकग्राउंड के रंग की सेटिंग को वापस लाता है. |
get | String | तय किए गए वर्ण के ऑफ़सेट पर बैकग्राउंड का रंग दिखाता है. |
get | String | फ़ॉन्ट फ़ैमिली की सेटिंग को वापस लाता है. |
get | String | तय किए गए वर्ण के ऑफ़सेट पर फ़ॉन्ट फ़ैमिली को वापस लाता है. |
get | Number | फ़ॉन्ट साइज़ की सेटिंग को वापस लाता है. |
get | Number | तय किए गए वर्ण के ऑफ़सेट पर फ़ॉन्ट का साइज़ दिखाता है. |
get | String | फ़ोरग्राउंड के रंग की सेटिंग को वापस लाता है. |
get | String | दिए गए वर्ण ऑफ़सेट पर फ़ोरग्राउंड का रंग दिखाता है. |
get | String | लिंक का यूआरएल दिखाता है. |
get | String | तय किए गए वर्ण के ऑफ़सेट पर, लिंक का यूआरएल दिखाता है. |
get | Element | एलिमेंट के अगले सिबलिंग एलिमेंट को वापस लाता है. |
get | Container | एलिमेंट का पैरंट एलिमेंट दिखाता है. |
get | Element | एलिमेंट के पिछले सिबलिंग एलिमेंट को वापस लाता है. |
get | String | एलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर दिखाता है. |
get | Text | टेक्स्ट अलाइनमेंट की जानकारी मिलती है. |
get | Text | किसी एक वर्ण के लिए टेक्स्ट अलाइनमेंट पाता है. |
get | Integer[] | टेक्स्ट इंडेक्स का वह सेट दिखाता है जो अलग-अलग टेक्स्ट फ़ॉर्मैटिंग के शुरू होने से जुड़ा होता है. |
get | Element | एलिमेंट का Element दिखाता है. |
insert | Text | दिए गए वर्ण ऑफ़सेट पर, तय किया गया टेक्स्ट डालता है. |
is | Boolean | यह तय करता है कि एलिमेंट, Document के आखिर में है या नहीं. |
is | Boolean | बोल्ड करने की सेटिंग दिखाता है. |
is | Boolean | दिए गए वर्ण के ऑफ़सेट पर, बोल्ड करने की सेटिंग को वापस लाता है. |
is | Boolean | इटैलिक सेटिंग को वापस लाता है. |
is | Boolean | दिए गए वर्ण ऑफ़सेट पर, इटैलिक की सेटिंग को वापस लाता है. |
is | Boolean | स्ट्राइकथ्रू की सेटिंग दिखाता है. |
is | Boolean | दिए गए वर्ण के ऑफ़सेट पर, स्ट्राइकथ्रू की सेटिंग को वापस लाता है. |
is | Boolean | अंडरलाइन की सेटिंग दिखाता है. |
is | Boolean | दिए गए वर्ण के ऑफ़सेट पर अंडरलाइन की सेटिंग को वापस लाता है. |
merge() | Text | एलिमेंट को उसी टाइप के पिछले सिबलिंग के साथ मर्ज करता है. |
remove | Text | एलिमेंट को उसके पैरंट से हटाता है. |
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
वर्शन पाता है.
एलिमेंट के कॉन्टेंट को रिच टेक्स्ट के तौर पर मैनिप्युलेट करने के लिए, 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
— मौजूदा एलिमेंट का टेक्स्ट वर्शन
findText(searchPattern)
रेगुलर एक्सप्रेशन का इस्तेमाल करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है.
JavaScript रेगुलर एक्सप्रेशन की कुछ सुविधाएं पूरी तरह काम नहीं करतीं. जैसे, कैप्चर ग्रुप और मोड मॉडिफ़ायर.
दिए गए रेगुलर एक्सप्रेशन पैटर्न का मिलान, मौजूदा एलिमेंट में मौजूद हर टेक्स्ट ब्लॉक से अलग-अलग किया जाता है.
पैरामीटर
नाम | टाइप | ब्यौरा |
---|---|---|
search | String | खोजने के लिए पैटर्न |
वापसी का टिकट
Range
— खोज के नतीजे में, खोज के लिए इस्तेमाल हुए टेक्स्ट की पोज़िशन दिखती है. अगर कोई मैच नहीं मिलता है, तो यह वैल्यू शून्य होती है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
findText(searchPattern, from)
किसी खोज के नतीजे से शुरू करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है.
JavaScript रेगुलर एक्सप्रेशन की कुछ सुविधाएं पूरी तरह काम नहीं करतीं. जैसे, कैप्चर ग्रुप और मोड मॉडिफ़ायर.
दिए गए रेगुलर एक्सप्रेशन पैटर्न का मिलान, मौजूदा एलिमेंट में मौजूद हर टेक्स्ट ब्लॉक से अलग-अलग किया जाता है.
पैरामीटर
नाम | टाइप | ब्यौरा |
---|---|---|
search | String | खोजने के लिए पैटर्न |
from | Range | खोज के जिस नतीजे में खोजना है |
वापसी का टिकट
Range
— खोज के नतीजे में, खोज के लिए इस्तेमाल हुए टेक्स्ट की अगली पोज़िशन दिखती है. अगर कोई मैच नहीं मिलता है, तो यह वैल्यू शून्य होती है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getAttributes()
एलिमेंट के एट्रिब्यूट दिखाता है.
इसका नतीजा एक ऑब्जेक्ट होता है, जिसमें हर मान्य एलिमेंट एट्रिब्यूट के लिए एक प्रॉपर्टी होती है. इसमें हर प्रॉपर्टी का नाम, 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
getAttributes(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
getBackgroundColor()
बैकग्राउंड के रंग की सेटिंग को वापस लाता है.
वापसी का टिकट
String
— बैकग्राउंड का रंग, सीएसएस नोटेशन (जैसे कि '#ffffff'
) में फ़ॉर्मैट किया गया या अगर एलिमेंट में इस एट्रिब्यूट के लिए एक से ज़्यादा वैल्यू हैं, तो शून्य
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getBackgroundColor(offset)
तय किए गए वर्ण के ऑफ़सेट पर बैकग्राउंड का रंग दिखाता है.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/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
— बैकग्राउंड का रंग, जिसे सीएसएस नोटेशन (जैसे कि '#ffffff'
) में फ़ॉर्मैट किया गया है.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getFontFamily()
फ़ॉन्ट फ़ैमिली की सेटिंग को वापस लाता है. नाम, Docs या Google Fonts के फ़ॉन्ट मेन्यू में मौजूद किसी भी फ़ॉन्ट का हो सकता है. साथ ही, नाम में केस-सेंसिटिव (बड़े और छोटे अक्षरों में अंतर) का ध्यान रखा जाता है. get
और set
तरीके अब
एनम के बजाय, फ़ॉन्ट के लिए स्ट्रिंग के नाम इस्तेमाल करते हैं. हालांकि, यह एनम अब काम नहीं करता, लेकिन पुरानी स्क्रिप्ट के साथ काम करने के लिए यह उपलब्ध रहेगा.Font
वापसी का टिकट
String
— फ़ॉन्ट फ़ैमिली या अगर एलिमेंट में इस एट्रिब्यूट के लिए एक से ज़्यादा वैल्यू हैं, तो शून्य
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getFontFamily(offset)
तय किए गए वर्ण के ऑफ़सेट पर फ़ॉन्ट फ़ैमिली को वापस लाता है. नाम, Docs के फ़ॉन्ट मेन्यू या Google Fonts में मौजूद किसी भी फ़ॉन्ट का हो सकता है. साथ ही, यह केस-सेंसिटिव होता है. get
और set
तरीकों में, अब
एनम के बजाय फ़ॉन्ट के लिए स्ट्रिंग नाम का इस्तेमाल किया जाता है. हालांकि, यह एनम अब काम नहीं करता, लेकिन पुरानी स्क्रिप्ट के साथ काम करने के लिए यह उपलब्ध रहेगा.
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
— फ़ॉन्ट फ़ैमिली.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getFontSize()
फ़ॉन्ट साइज़ की सेटिंग को वापस लाता है.
वापसी का टिकट
Number
— फ़ॉन्ट साइज़ या अगर एलिमेंट में इस एट्रिब्यूट के लिए एक से ज़्यादा वैल्यू हैं, तो शून्य
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getFontSize(offset)
तय किए गए वर्ण के ऑफ़सेट पर फ़ॉन्ट का साइज़ दिखाता है.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/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
— फ़ॉन्ट का साइज़.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getForegroundColor()
फ़ोरग्राउंड के रंग की सेटिंग को वापस लाता है.
वापसी का टिकट
String
— फ़ोरग्राउंड का रंग, जिसे सीएसएस नोटेशन (जैसे, '#ffffff'
) में फ़ॉर्मैट किया गया है या अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू हैं, तो शून्य
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getForegroundColor(offset)
दिए गए वर्ण ऑफ़सेट पर फ़ोरग्राउंड का रंग दिखाता है.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/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
— फ़ोरग्राउंड का रंग, जिसे सीएसएस नोटेशन (जैसे कि '#ffffff'
) में फ़ॉर्मैट किया गया है.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getLinkUrl()
लिंक का यूआरएल दिखाता है.
वापसी का टिकट
String
— लिंक का यूआरएल या अगर एलिमेंट में इस एट्रिब्यूट के लिए एक से ज़्यादा वैल्यू हैं, तो शून्य
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getLinkUrl(offset)
तय किए गए वर्ण के ऑफ़सेट पर, लिंक का यूआरएल दिखाता है.
// Opens the Docs file by its URL. If you created your script from within a // Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the URL with your own. const doc = DocumentApp.openByUrl( 'https://docs.google.com/document/d/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
— लिंक का यूआरएल.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getNextSibling()
एलिमेंट के अगले सिबलिंग एलिमेंट को वापस लाता है.
अगले सिबलिंग का पैरंट एक ही होता है और वह मौजूदा एलिमेंट के बाद आता है.
वापसी का टिकट
Element
— अगला सिबलिंग एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getParent()
एलिमेंट का पैरंट एलिमेंट दिखाता है.
पैरंट एलिमेंट में मौजूदा एलिमेंट होता है.
वापसी का टिकट
Container
— पैरंट एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getPreviousSibling()
एलिमेंट के पिछले सिबलिंग एलिमेंट को वापस लाता है.
पिछले सिबलिंग का पैरंट एक ही है और वह मौजूदा एलिमेंट से पहले आता है.
वापसी का टिकट
Element
— सिबलिंग एलिमेंट का पिछला एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getText()
एलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर दिखाता है.
वापसी का टिकट
String
— टेक्स्ट स्ट्रिंग के तौर पर एलिमेंट का कॉन्टेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getTextAlignment()
टेक्स्ट अलाइनमेंट की जानकारी मिलती है. अलाइनमेंट के लिए ये टाइप उपलब्ध हैं: Document
, Document
, और Document
.
वापसी का टिकट
Text
— टेक्स्ट अलाइनमेंट का टाइप या null
, अगर टेक्स्ट में एक से ज़्यादा तरह के टेक्स्ट अलाइनमेंट हैं या टेक्स्ट अलाइनमेंट कभी सेट नहीं किया गया है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getTextAlignment(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
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()
एलिमेंट का 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
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
— बोल्ड सेटिंग.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
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
— इटैलिक सेटिंग.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
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
— स्ट्राइकथ्रू की सेटिंग.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
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
— अंडरलाइन करने की सेटिंग.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
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
— मर्ज किया गया एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
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
— हटाया गया एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या एक से ज़्यादा स्कोप के लिए अनुमति की ज़रूरत होती है:
-
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)
दिए गए वर्ण की सीमा पर, तय किए गए एट्रिब्यूट लागू करता है.
एट्रिब्यूट पैरामीटर, एक ऑब्जेक्ट होना चाहिए. इसमें हर प्रॉपर्टी का नाम, 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
setAttributes(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
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 के तौर पर रेंडर होंगे. get
और
set
तरीके अब फ़ॉन्ट के लिए
एनम के बजाय स्ट्रिंग के नाम का इस्तेमाल करते हैं. हालांकि, यह एनम अब काम नहीं करता, लेकिन पुरानी स्क्रिप्ट के साथ काम करने के लिए यह उपलब्ध रहेगा.
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
setFontFamily(fontFamilyName)
फ़ॉन्ट फ़ैमिली सेट करता है. नाम, Docs या Google Fonts के फ़ॉन्ट मेन्यू में मौजूद किसी भी फ़ॉन्ट का हो सकता है. साथ ही, नाम में केस-सेंसिटिव (बड़े और छोटे अक्षरों में अंतर) का ध्यान रखा जाता है. जिन फ़ॉन्ट के नामों की पहचान नहीं की जा सकी है वे Arial के तौर पर रेंडर होंगे. get
और set
तरीके, अब फ़ॉन्ट के लिए
एनम के बजाय स्ट्रिंग नेम का इस्तेमाल करते हैं. हालांकि, यह एनम अब काम नहीं करता, लेकिन पुरानी स्क्रिप्ट के साथ काम करने के लिए यह उपलब्ध रहेगा.Font
पैरामीटर
नाम | टाइप | ब्यौरा |
---|---|---|
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)
किसी वर्ण सीमा के लिए टेक्स्ट अलाइनमेंट सेट करता है. अलाइनमेंट के ये टाइप उपलब्ध हैं:
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
setTextAlignment(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
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