पेज ब्रेक को दिखाने वाला एलिमेंट. PageBreak को ListItem या Paragraph में शामिल किया जा सकता है. हालांकि, अगर ListItem या Paragraph, Table, HeaderSection, FooterSection या FootnoteSection में शामिल है, तो ऐसा नहीं किया जा सकता. PageBreak में कोई दूसरा एलिमेंट शामिल नहीं किया जा सकता. दस्तावेज़ के स्ट्रक्चर के बारे में ज़्यादा जानने के लिए, Google Docs को एक्सटेंड करने से जुड़ी गाइड देखें.
तरीके
| तरीका | रिटर्न टाइप | संक्षिप्त विवरण |
|---|---|---|
copy() | Page | यह फ़ंक्शन, मौजूदा एलिमेंट की अलग की गई डीप कॉपी दिखाता है. |
get | Object | यह एलिमेंट के एट्रिब्यूट वापस लाता है. |
get | Element|null | यह एलिमेंट के अगले सिबलिंग एलिमेंट को वापस लाता है. |
get | Container | यह एलिमेंट के पैरंट एलिमेंट को वापस लाता है. |
get | Element|null | यह एलिमेंट के पिछले सिबलिंग एलिमेंट को वापस लाता है. |
get | Element | यह एलिमेंट के Element को वापस लाता है. |
is | Boolean | इससे यह तय होता है कि एलिमेंट, Document के आखिर में है या नहीं. |
remove | Page | इस फ़ंक्शन का इस्तेमाल करके, एलिमेंट को उसके पैरंट से हटाया जा सकता है. |
set | Page | यह एलिमेंट के एट्रिब्यूट सेट करता है. |
ज़्यादा जानकारी वाला दस्तावेज़
copy()
यह फ़ंक्शन, मौजूदा एलिमेंट की अलग की गई डीप कॉपी दिखाता है.
तत्व में मौजूद सभी चाइल्ड एलिमेंट भी कॉपी किए जाते हैं. नए एलिमेंट का कोई पैरंट नहीं है.
वापसी का टिकट
PageBreak — नई कॉपी.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getAttributes()
यह एलिमेंट के एट्रिब्यूट वापस लाता है.
नतीजा एक ऐसा ऑब्जेक्ट होता है जिसमें हर मान्य एलिमेंट एट्रिब्यूट के लिए एक प्रॉपर्टी होती है. इसमें हर प्रॉपर्टी का नाम, DocumentApp.Attribute इन्यूमरेशन में मौजूद किसी आइटम से मेल खाता है.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Append a styled paragraph. const par = body.appendParagraph('A bold, italicized paragraph.'); par.setBold(true); par.setItalic(true); // Retrieve the paragraph's attributes. const atts = par.getAttributes(); // Log the paragraph attributes. for (const att in atts) { Logger.log(`${att}:${atts[att]}`); }
वापसी का टिकट
Object — एलिमेंट के एट्रिब्यूट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getNextSibling()
यह एलिमेंट के अगले सिबलिंग एलिमेंट को वापस लाता है.
अगले सिबलिंग का पैरंट वही होता है जो मौजूदा एलिमेंट का होता है. साथ ही, यह मौजूदा एलिमेंट के बाद आता है.
वापसी का टिकट
Element|null — अगला सिबलिंग एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getParent()
यह एलिमेंट के पैरंट एलिमेंट को वापस लाता है.
पैरंट एलिमेंट में मौजूदा एलिमेंट शामिल है.
वापसी का टिकट
ContainerElement|null — पैरंट एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getPreviousSibling()
यह एलिमेंट के पिछले सिबलिंग एलिमेंट को वापस लाता है.
पिछला सिबलिंग, मौजूदा एलिमेंट से पहले आता है और उसका पैरंट एलिमेंट भी मौजूदा एलिमेंट जैसा ही होता है.
वापसी का टिकट
Element|null — पिछला सिबलिंग एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getType()
यह एलिमेंट के ElementType को वापस लाता है.
किसी एलिमेंट के टाइप का पता लगाने के लिए, getType() का इस्तेमाल करें.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Obtain the first element in the active tab's body. const firstChild = body.getChild(0); // Use getType() to determine the element's type. if (firstChild.getType() === DocumentApp.ElementType.PARAGRAPH) { Logger.log('The first element is a paragraph.'); } else { Logger.log('The first element is not a paragraph.'); }
वापसी का टिकट
ElementType — एलिमेंट का टाइप.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
isAtDocumentEnd()
इससे यह तय होता है कि एलिमेंट, Document के आखिर में है या नहीं.
वापसी का टिकट
Boolean — इससे पता चलता है कि एलिमेंट टैब के आखिर में है या नहीं.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
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(); }
वापसी का टिकट
PageBreak|null — हटाया गया एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setAttributes(attributes)
यह एलिमेंट के एट्रिब्यूट सेट करता है.
तय किया गया एट्रिब्यूट पैरामीटर एक ऑब्जेक्ट होना चाहिए. इसमें हर प्रॉपर्टी का नाम, DocumentApp.Attribute इन्यूमरेशन में मौजूद एक आइटम होता है. साथ ही, हर प्रॉपर्टी की वैल्यू, लागू की जाने वाली नई वैल्यू होती है.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Define a custom paragraph style. const style = {}; style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] = DocumentApp.HorizontalAlignment.RIGHT; style[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri'; style[DocumentApp.Attribute.FONT_SIZE] = 18; style[DocumentApp.Attribute.BOLD] = true; // Append a plain paragraph. const par = body.appendParagraph('A paragraph with custom style.'); // Apply the custom style. par.setAttributes(style);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
attributes | Object | एलिमेंट के एट्रिब्यूट. |
वापसी का टिकट
PageBreak — मौजूदा एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents