ऐसा क्षेत्र दिखाने वाला एलिमेंट जो अज्ञात है या जिस पर स्क्रिप्ट का कोई असर नहीं पड़ सकता, जैसे कि पेज नंबर.
तरीके
तरीका | रिटर्न टाइप | संक्षिप्त विवरण |
---|---|---|
copy() | UnsupportedElement | मौजूदा एलिमेंट की डिटैच की गई और डीप कॉपी दिखाता है. |
getAttributes() | Object | एलिमेंट के एट्रिब्यूट वापस लाता है. |
getNextSibling() | Element | एलिमेंट का अगला सिबलिंग एलिमेंट वापस लाता है. |
getParent() | ContainerElement | एलिमेंट के पैरंट एलिमेंट को वापस लाता है. |
getPreviousSibling() | Element | एलिमेंट के पिछले सिबलिंग एलिमेंट को फिर से लाता है. |
getType() | ElementType | एलिमेंट के ElementType को फिर से लाता है. |
isAtDocumentEnd() | Boolean | इससे पता चलता है कि एलिमेंट, Document के आखिर में है या नहीं. |
merge() | UnsupportedElement | एलिमेंट को उसी तरह के पिछले सिबलिंग के साथ मर्ज करता है. |
removeFromParent() | UnsupportedElement | इसके पैरंट से एलिमेंट हटा देता है. |
setAttributes(attributes) | UnsupportedElement | एलिमेंट के एट्रिब्यूट सेट करता है. |
ज़्यादा जानकारी के साथ दस्तावेज़
copy()
मौजूदा एलिमेंट की डिटैच की गई और डीप कॉपी दिखाता है.
एलिमेंट में मौजूद सभी चाइल्ड एलिमेंट भी कॉपी हो जाते हैं. नए एलिमेंट में पैरंट एलिमेंट नहीं होता.
रिटर्न
UnsupportedElement
— नई कॉपी.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getAttributes()
एलिमेंट के एट्रिब्यूट वापस लाता है.
नतीजा एक ऑब्जेक्ट होता है, जिसमें हर मान्य एलिमेंट एट्रिब्यूट के लिए एक प्रॉपर्टी होती है. यहां हर प्रॉपर्टी का नाम, DocumentApp.Attribute
की गिनती में मौजूद किसी आइटम से मेल खाता है.
var body = DocumentApp.getActiveDocument().getBody(); // Append a styled paragraph. var par = body.appendParagraph('A bold, italicized paragraph.'); par.setBold(true); par.setItalic(true); // Retrieve the paragraph's attributes. var atts = par.getAttributes(); // Log the paragraph attributes. for (var att in atts) { Logger.log(att + ":" + atts[att]); }
रिटर्न
Object
— एलिमेंट के एट्रिब्यूट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getNextSibling()
एलिमेंट का अगला सिबलिंग एलिमेंट वापस लाता है.
अगले सिबलिंग का एक ही पैरंट है और वह मौजूदा एलिमेंट को फ़ॉलो करता है.
रिटर्न
Element
— अगला सिबलिंग एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getParent()
एलिमेंट के पैरंट एलिमेंट को वापस लाता है.
पैरंट एलिमेंट में मौजूदा एलिमेंट शामिल है.
रिटर्न
ContainerElement
— पैरंट एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getPreviousSibling()
एलिमेंट के पिछले सिबलिंग एलिमेंट को फिर से लाता है.
पिछले सिबलिंग का पैरंट एलिमेंट एक ही है और यह मौजूदा एलिमेंट से पहले लागू है.
रिटर्न
Element
— पिछला सिबलिंग एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getType()
एलिमेंट के ElementType
को फिर से लाता है.
दिए गए एलिमेंट का सही टाइप पता करने के लिए, getType()
का इस्तेमाल करें.
var body = DocumentApp.getActiveDocument().getBody(); // Obtain the first element in the document body. var firstChild = body.getChild(0); // Use getType() to determine the element's type. if (firstChild.getType() == DocumentApp.ElementType.PARAGRAPH) { Logger.log('The first element is a paragraph.'); } else { Logger.log('The first element is not a paragraph.'); }
रिटर्न
ElementType
— एलिमेंट का टाइप.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
isAtDocumentEnd()
इससे पता चलता है कि एलिमेंट, Document
के आखिर में है या नहीं.
रिटर्न
Boolean
— एलिमेंट, दस्तावेज़ के आखिर में है या नहीं.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
merge()
एलिमेंट को उसी तरह के पिछले सिबलिंग के साथ मर्ज करता है.
एक ही ElementType
के एलिमेंट को ही मर्ज किया जा सकता है. मौजूदा एलिमेंट में शामिल सभी चाइल्ड एलिमेंट
को पिछले सिबलिंग एलिमेंट में ले जाया जाता है.
मौजूदा एलिमेंट, दस्तावेज़ से हटा दिया गया है.
var body = DocumentApp.getActiveDocument().getBody(); // Example 1: Merge paragraphs // Append two paragraphs to the document. var par1 = body.appendParagraph('Paragraph 1.'); var par2 = body.appendParagraph('Paragraph 2.'); // Merge the newly added paragraphs into a single paragraph. par2.merge(); // Example 2: Merge table cells // Create a two-dimensional array containing the table's cell contents. var cells = [ ['Row 1, Cell 1', 'Row 1, Cell 2'], ['Row 2, Cell 1', 'Row 2, Cell 2'] ]; // Build a table from the array. var table = body.appendTable(cells); // Get the first row in the table. var row = table.getRow(0); // Get the two cells in this row. var cell1 = row.getCell(0); var cell2 = row.getCell(1); // Merge the current cell into its preceding sibling element. var merged = cell2.merge();
रिटर्न
UnsupportedElement
— मर्ज किया गया एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
removeFromParent()
इसके पैरंट से एलिमेंट हटा देता है.
var body = DocumentApp.getActiveDocument().getBody(); // Remove all images in the document body. var imgs = body.getImages(); for (var i = 0; i < imgs.length; i++) { imgs[i].removeFromParent(); }
रिटर्न
UnsupportedElement
— हटाया गया एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
setAttributes(attributes)
एलिमेंट के एट्रिब्यूट सेट करता है.
बताया गया एट्रिब्यूट पैरामीटर एक ऐसा ऑब्जेक्ट होना चाहिए जहां हर प्रॉपर्टी का नाम, DocumentApp.Attribute
इन्यूरेशन में मौजूद एक आइटम हो. साथ ही, हर प्रॉपर्टी की वैल्यू वह नई वैल्यू हो जिसे लागू किया जाना है.
var body = DocumentApp.getActiveDocument().getBody(); // Define a custom paragraph style. var style = {}; style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.RIGHT; style[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri'; style[DocumentApp.Attribute.FONT_SIZE] = 18; style[DocumentApp.Attribute.BOLD] = true; // Append a plain paragraph. var par = body.appendParagraph('A paragraph with custom style.'); // Apply the custom style. par.setAttributes(style);
पैरामीटर
नाम | Type | ब्यौरा |
---|---|---|
attributes | Object | एलिमेंट के एट्रिब्यूट. |
रिटर्न
UnsupportedElement
— मौजूदा एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट को, इनमें से एक या ज़्यादा स्कोप से अनुमति देने की ज़रूरत होती है:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents