यह एलिमेंट, पैराग्राफ़ को दिखाता है. Paragraph में Equation, Footnote, HorizontalRule, InlineDrawing, InlineImage, PageBreak, और Text एलिमेंट हो सकते हैं. दस्तावेज़ के स्ट्रक्चर के बारे में ज़्यादा जानने के लिए, Google Docs को एक्सटेंड करने से जुड़ी गाइड देखें.
Paragraphs में नई लाइन वाले वर्ण नहीं हो सकते. नई लाइन वाले वर्ण ("\n") को लाइन ब्रेक वाले वर्णों ("\r") में बदल दिया जाता है.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Append a tab header paragraph. const header = body.appendParagraph('A Document'); header.setHeading(DocumentApp.ParagraphHeading.HEADING1); // Append a section header paragraph. const section = body.appendParagraph('Section 1'); section.setHeading(DocumentApp.ParagraphHeading.HEADING2); // Append a regular paragraph. body.appendParagraph('This is a typical paragraph.');
तरीके
| तरीका | रिटर्न टाइप | संक्षिप्त विवरण |
|---|---|---|
add | Positioned | यह फ़ंक्शन, दी गई इमेज के बड़े बाइनरी ऑब्जेक्ट (ब्लॉब) से नया Positioned बनाता है और उसे डालता है. |
append | Horizontal | यह एक नया Horizontal बनाता है और उसे जोड़ता है. |
append | Inline | यह फ़ंक्शन, दी गई इमेज के बड़े बाइनरी ऑब्जेक्ट (ब्लॉब) से नया Inline बनाता है और उसे जोड़ता है. |
append | Inline | दिए गए Inline को जोड़ता है. |
append | Page | यह एक नया Page बनाता है और उसे जोड़ता है. |
append | Page | दिए गए Page को जोड़ता है. |
append | Text | यह तय किए गए कॉन्टेंट के साथ एक नया Text एलिमेंट बनाता है और उसे जोड़ता है. |
append | Text | यह दिए गए Text एलिमेंट को जोड़ता है. |
clear() | Paragraph | इससे एलिमेंट का कॉन्टेंट मिट जाता है. |
copy() | Paragraph | यह फ़ंक्शन, मौजूदा एलिमेंट की अलग की गई डीप कॉपी दिखाता है. |
edit | Text | बदलाव करने के लिए, मौजूदा एलिमेंट का Text वर्शन मिलता है. |
find | Range | यह फ़ंक्शन, एलिमेंट के कॉन्टेंट में, तय किए गए टाइप के डिसेंडेंट को खोजता है. |
find | Range | यह फ़ंक्शन, एलिमेंट के कॉन्टेंट में दिए गए टाइप के डिसेंडेंट को खोजता है. यह खोज, दिए गए Range से शुरू होती है. |
find | Range | रेगुलर एक्सप्रेशन का इस्तेमाल करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है. |
find | Range | यह फ़ंक्शन, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है. यह खोज, दिए गए खोज नतीजे से शुरू होती है. |
get | Horizontal | यह कुकी, Horizontal को वापस लाती है. |
get | Object | यह एलिमेंट के एट्रिब्यूट वापस लाता है. |
get | Element | यह फ़ंक्शन, दिए गए चाइल्ड इंडेक्स पर मौजूद चाइल्ड एलिमेंट को वापस लाता है. |
get | Integer | यह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट के लिए चाइल्ड इंडेक्स को वापस लाता है. |
get | Paragraph | यह कुकी, Paragraph को वापस लाती है. |
get | Number|null | यह फ़ंक्शन, इंडेंटेशन के आखिर में मौजूद पॉइंट को वापस लाता है. |
get | Number|null | यह पहली लाइन के इंडेंटेशन को पॉइंट में दिखाता है. |
get | Number|null | इससे इंडेंटेशन की शुरुआती जगह मिलती है. |
get | Number|null | यह लाइन स्पेसिंग को पॉइंट में दिखाता है. |
get | String|null | यह कुकी, लिंक का यूआरएल वापस पाती है. |
get | Element|null | यह एलिमेंट के अगले सिबलिंग एलिमेंट को वापस लाता है. |
get | Integer | इससे बच्चों की संख्या मिलती है. |
get | Container | यह एलिमेंट के पैरंट एलिमेंट को वापस लाता है. |
get | Positioned | इमेज के आईडी के हिसाब से, Positioned मिलता है. |
get | Positioned | पैराग्राफ़ से जुड़े सभी Positioned ऑब्जेक्ट मिलते हैं. |
get | Element|null | यह एलिमेंट के पिछले सिबलिंग एलिमेंट को वापस लाता है. |
get | Number|null | यह फ़ंक्शन, एलिमेंट के बाद की जगह की जानकारी पॉइंट में दिखाता है. |
get | Number|null | यह एलिमेंट से पहले की स्पेस को पॉइंट में दिखाता है. |
get | String | यह फ़ंक्शन, एलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर वापस लाता है. |
get | Text | टेक्स्ट अलाइनमेंट की जानकारी मिलती है. |
get | Element | यह एलिमेंट के Element को वापस लाता है. |
insert | Horizontal | यह फ़ंक्शन, तय किए गए इंडेक्स पर Horizontal बनाता है और उसे डालता है. |
insert | Inline | यह फ़ंक्शन, दी गई इमेज के ब्यौरे से एक नया Inline बनाता है और उसे दिए गए इंडेक्स पर डालता है. |
insert | Inline | यह फ़ंक्शन, दिए गए इंडेक्स पर Inline को शामिल करता है. |
insert | Page | यह तय किए गए इंडेक्स पर, नया Page बनाता है और उसे डालता है. |
insert | Page | यह फ़ंक्शन, दिए गए इंडेक्स पर Page को शामिल करता है. |
insert | Text | यह तय किए गए इंडेक्स पर, नया टेक्स्ट एलिमेंट बनाता है और उसे जोड़ता है. |
insert | Text | यह दिए गए Text एलिमेंट को बताए गए इंडेक्स पर, बताए गए टेक्स्ट कॉन्टेंट के साथ डालता है. |
is | Boolean | इससे यह तय होता है कि एलिमेंट, Document के आखिर में है या नहीं. |
is | Boolean|null | यह कुकी, बाएं से दाएं की सेटिंग को वापस लाती है. |
merge() | Paragraph|null | इस विकल्प का इस्तेमाल करके, एलिमेंट को उसी तरह के पिछले सिबलिंग के साथ मर्ज किया जाता है. |
remove | Paragraph | यह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट को हटाता है. |
remove | Paragraph|null | इस फ़ंक्शन का इस्तेमाल करके, एलिमेंट को उसके पैरंट से हटाया जा सकता है. |
remove | Boolean | यह इमेज के आईडी के हिसाब से, Positioned को हटाता है. |
replace | Element | रेगुलर एक्सप्रेशन का इस्तेमाल करके, दिए गए टेक्स्ट पैटर्न की सभी जगहों पर, दिए गए रिप्लेसमेंट स्ट्रिंग को बदलता है. |
set | Paragraph | Horizontal को सेट करता है. |
set | Paragraph | यह एलिमेंट के एट्रिब्यूट सेट करता है. |
set | Paragraph | Paragraph को सेट करता है. |
set | Paragraph | यह विकल्प, इंडेंटेशन के खत्म होने की जगह को पॉइंट में सेट करता है. |
set | Paragraph | यह विकल्प, पहली लाइन के इंडेंट को पॉइंट में सेट करता है. |
set | Paragraph | यह विकल्प, इंडेंटेशन की शुरुआती जगह को पॉइंट में सेट करता है. |
set | Paragraph | यह कुकी, बाएं से दाएं की सेटिंग सेट करती है. |
set | Paragraph | लाइन स्पेसिंग सेट करता है. यह एक ऐसी संख्या होती है जिससे पता चलता है कि स्पेसिंग के लिए कितनी लाइनों का इस्तेमाल करना है. |
set | Paragraph | यह लिंक का यूआरएल सेट करता है. |
set | Paragraph | यह विकल्प, एलिमेंट के बाद की जगह को पॉइंट में सेट करता है. |
set | Paragraph | यह विकल्प, एलिमेंट के पहले की स्पेस को पॉइंट में सेट करता है. |
set | void | इस विकल्प से, पैराग्राफ़ के कॉन्टेंट को टेक्स्ट के तौर पर सेट किया जाता है. |
set | Paragraph | इससे टेक्स्ट अलाइनमेंट सेट किया जाता है. |
ज़्यादा जानकारी वाला दस्तावेज़
addPositionedImage(image)
यह फ़ंक्शन, दी गई इमेज के बड़े बाइनरी ऑब्जेक्ट (ब्लॉब) से नया PositionedImage बनाता है और उसे डालता है.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // 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 first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Fetches the specified image URL. const image = UrlFetchApp.fetch( 'https://fonts.gstatic.com/s/i/productlogos/apps_script/v10/web-24dp/logo_apps_script_color_1x_web_24dp.png', ); // Adds the image to the tab, anchored to the first paragraph. paragraph.addPositionedImage(image);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
image | Blob | इमेज का डेटा. |
वापसी का टिकट
PositionedImage — नई जगह पर मौजूद इमेज.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendHorizontalRule()
यह एक नया HorizontalRule बनाता है और उसे जोड़ता है.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // 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 first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Adds a horizontal line under the first paragraph. paragraph.appendHorizontalRule();
वापसी का टिकट
HorizontalRule — नया हॉरिज़ॉन्टल रूल.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendInlineImage(image)
यह फ़ंक्शन, दी गई इमेज के बड़े बाइनरी ऑब्जेक्ट (ब्लॉब) से नया InlineImage बनाता है और उसे जोड़ता है.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // 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 first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Fetches the image from the specified image URL. const image = UrlFetchApp.fetch( 'https://fonts.gstatic.com/s/i/productlogos/apps_script/v10/web-96dp/logo_apps_script_color_1x_web_96dp.png', ); // Adds the image to the first paragraph. paragraph.appendInlineImage(image);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
image | Blob | इमेज का डेटा. |
वापसी का टिकट
InlineImage — जोड़ी गई इमेज.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendInlineImage(image)
दिए गए InlineImage को जोड़ता है.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // 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 first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Makes a copy of the first image in the body. const image = body.getImages()[0].copy(); // Adds the image to the first paragraph. paragraph.appendInlineImage(image);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
image | Inline | इमेज का डेटा. |
वापसी का टिकट
InlineImage — जोड़ी गई इमेज.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendPageBreak()
यह एक नया PageBreak बनाता है और उसे जोड़ता है.
ध्यान दें: ऐसा हो सकता है कि PageBreaks, TableCells में शामिल न हो.
अगर मौजूदा एलिमेंट, टेबल सेल में शामिल है, तो एक अपवाद दिखेगा.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // 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 first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Adds a page break after the first paragraph. paragraph.appendPageBreak();
वापसी का टिकट
PageBreak — यह नया पेज ब्रेक एलिमेंट है.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendPageBreak(pageBreak)
दिए गए PageBreak को जोड़ता है.
ध्यान दें: PageBreaks को TableCells में शामिल नहीं किया जा सकता.
अगर मौजूदा एलिमेंट, टेबल सेल में मौजूद है, तो स्क्रिप्ट एक अपवाद दिखाती है.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // 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 first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Adds a page break after the first paragraph. const pageBreak = paragraph.appendPageBreak(); // Makes a copy of the page break. const newPageBreak = pageBreak.copy(); // Adds the copied page break to the paragraph. paragraph.appendPageBreak(newPageBreak);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
page | Page | जोड़ा जाने वाला पेज ब्रेक. |
वापसी का टिकट
PageBreak — जोड़ा गया पेज ब्रेक एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendText(text)
यह तय किए गए कॉन्टेंट के साथ एक नया Text एलिमेंट बनाता है और उसे जोड़ता है.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // 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 first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Adds a string to the paragraph. paragraph.appendText('This is a new sentence.');
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
text | String | टेक्स्ट कॉन्टेंट. |
वापसी का टिकट
Text — नया टेक्स्ट एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendText(text)
यह दिए गए Text एलिमेंट को जोड़ता है.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // 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 from the first paragraph in the body. const paragraph1 = body.getParagraphs()[0]; const text = paragraph1.getText(); // Gets the third paragraph in the body. const paragraph3 = body.getParagraphs()[2]; // Adds the text from the first paragraph to the third paragraph. paragraph3.appendText(text);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
text | Text | जोड़ने के लिए टेक्स्ट एलिमेंट. |
वापसी का टिकट
Text — जोड़ा गया टेक्स्ट एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
clear()
copy()
यह फ़ंक्शन, मौजूदा एलिमेंट की अलग की गई डीप कॉपी दिखाता है.
तत्व में मौजूद सभी चाइल्ड एलिमेंट भी कॉपी किए जाते हैं. नए एलिमेंट का कोई पैरंट नहीं है.
वापसी का टिकट
Paragraph — नई कॉपी.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
editAsText()
बदलाव करने के लिए, मौजूदा एलिमेंट का Text वर्शन मिलता है.
रिच टेक्स्ट के तौर पर एलिमेंट के कॉन्टेंट में बदलाव करने के लिए, editAsText का इस्तेमाल करें. editAsText मोड में, टेक्स्ट के अलावा अन्य एलिमेंट (जैसे कि InlineImage और HorizontalRule) को अनदेखा कर दिया जाता है.
मिटाए गए टेक्स्ट रेंज में पूरी तरह से शामिल चाइल्ड एलिमेंट को एलिमेंट से हटा दिया जाता है.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Insert two paragraphs separated by a paragraph containing an // horizontal rule. body.insertParagraph(0, 'An editAsText sample.'); body.insertHorizontalRule(0); body.insertParagraph(0, 'An example.'); // Delete " sample.\n\n An" removing the horizontal rule in the process. body.editAsText().deleteText(14, 25);
वापसी का टिकट
Text — मौजूदा एलिमेंट का टेक्स्ट वर्शन
findElement(elementType)
यह फ़ंक्शन, एलिमेंट के कॉन्टेंट में, तय किए गए टाइप के डिसेंडेंट को खोजता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
element | Element | खोजे जाने वाले एलिमेंट का टाइप. |
वापसी का टिकट
RangeElement|null — खोज के नतीजे में, खोज के एलिमेंट की जगह के बारे में जानकारी देने वाला सर्च एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
findElement(elementType, from)
यह फ़ंक्शन, एलिमेंट के कॉन्टेंट में दिए गए टाइप के डिसेंडेंट को खोजता है. यह खोज, दिए गए RangeElement से शुरू होती है.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Define the search parameters. let searchResult = null; // Search until the paragraph is found. while ( (searchResult = body.findElement( DocumentApp.ElementType.PARAGRAPH, searchResult, ))) { const par = searchResult.getElement().asParagraph(); if (par.getHeading() === DocumentApp.ParagraphHeading.HEADING1) { // Found one, update and stop. par.setText('This is the first header.'); break; } }
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
element | Element | खोजे जाने वाले एलिमेंट का टाइप. |
from | Range | वह खोज नतीजा जिससे खोज करनी है. |
वापसी का टिकट
RangeElement|null — खोज के नतीजे में, खोज के एलिमेंट की अगली पोज़िशन के बारे में जानकारी देने वाला नतीजा.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
findText(searchPattern)
रेगुलर एक्सप्रेशन का इस्तेमाल करके, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है.
JavaScript रेगुलर एक्सप्रेशन की कुछ सुविधाओं का पूरी तरह से इस्तेमाल नहीं किया जा सकता. जैसे, कैप्चर ग्रुप और मोड मॉडिफ़ायर.
दिए गए रेगुलर एक्सप्रेशन पैटर्न का मिलान, मौजूदा एलिमेंट में मौजूद हर टेक्स्ट ब्लॉक से अलग-अलग किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
search | String | खोजने के लिए पैटर्न |
वापसी का टिकट
RangeElement|null — खोज के नतीजे में खोजे गए टेक्स्ट की पोज़िशन दिखाता है. अगर कोई मैच नहीं मिलता है, तो यह शून्य होता है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
findText(searchPattern, from)
यह फ़ंक्शन, एलिमेंट के कॉन्टेंट में दिए गए टेक्स्ट पैटर्न को खोजता है. यह खोज, दिए गए खोज नतीजे से शुरू होती है.
JavaScript रेगुलर एक्सप्रेशन की कुछ सुविधाओं का पूरी तरह से इस्तेमाल नहीं किया जा सकता. जैसे, कैप्चर ग्रुप और मोड मॉडिफ़ायर.
दिए गए रेगुलर एक्सप्रेशन पैटर्न का मिलान, मौजूदा एलिमेंट में मौजूद हर टेक्स्ट ब्लॉक से अलग-अलग किया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
search | String | खोजने के लिए पैटर्न |
from | Range | खोज के नतीजे में मौजूद वह आइटम जिससे खोज करनी है |
वापसी का टिकट
RangeElement|null — खोज के नतीजे में, खोजे गए टेक्स्ट की अगली पोज़िशन दिखाता है. अगर कोई मैच नहीं मिलता है, तो यह शून्य होता है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getAlignment()
यह कुकी, HorizontalAlignment को वापस लाती है.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // 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 first paragraph from the body. const paragraph = body.getParagraphs()[0]; // Sets the horizontal alignment to left for the first paragraph. paragraph.setAlignment(DocumentApp.HorizontalAlignment.LEFT); // Gets the horizontal alignment of the first paragraph and logs it to the // console. console.log(paragraph.getAlignment().toString());
वापसी का टिकट
HorizontalAlignment|null — अलाइनमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getAttributes()
यह एलिमेंट के एट्रिब्यूट वापस लाता है.
नतीजा एक ऐसा ऑब्जेक्ट होता है जिसमें हर मान्य एलिमेंट एट्रिब्यूट के लिए एक प्रॉपर्टी होती है. इसमें हर प्रॉपर्टी का नाम, DocumentApp.Attribute इन्यूमरेशन में मौजूद किसी आइटम से मेल खाता है.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Append a styled paragraph. const par = body.appendParagraph('A bold, italicized paragraph.'); par.setBold(true); par.setItalic(true); // Retrieve the paragraph's attributes. const atts = par.getAttributes(); // Log the paragraph attributes. for (const att in atts) { Logger.log(`${att}:${atts[att]}`); }
वापसी का टिकट
Object — एलिमेंट के एट्रिब्यूट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getChild(childIndex)
यह फ़ंक्शन, दिए गए चाइल्ड इंडेक्स पर मौजूद चाइल्ड एलिमेंट को वापस लाता है.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Obtain the first element in the tab. const firstChild = body.getChild(0); // If it's a paragraph, set its contents. if (firstChild.getType() === DocumentApp.ElementType.PARAGRAPH) { firstChild.asParagraph().setText('This is the first paragraph.'); }
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Integer | जिस चाइल्ड एलिमेंट को वापस पाना है उसका इंडेक्स. |
वापसी का टिकट
Element — यह बताए गए इंडेक्स पर मौजूद चाइल्ड एलिमेंट होता है.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getChildIndex(child)
यह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट के लिए चाइल्ड इंडेक्स को वापस लाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Element | वह चाइल्ड एलिमेंट जिसके लिए इंडेक्स वापस पाना है. |
वापसी का टिकट
Integer — बच्चे का इंडेक्स.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getHeading()
यह कुकी, ParagraphHeading को वापस लाती है.
// Opens the Docs file by its ID. If you created your script from within // a Google Docs file, you can use DocumentApp.getActiveDocument() instead. // TODO(developer): Replace the ID with your own. const doc = DocumentApp.openById('123abc'); // 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 a paragraph to the body. const paragraph = body.appendParagraph('Title heading'); // Sets the paragraph heading style to 'Title.' paragraph.setHeading(DocumentApp.ParagraphHeading.TITLE); // Gets the heading style and logs it to the console. console.log(paragraph.getHeading().toString());
वापसी का टिकट
ParagraphHeading|null — हेडिंग.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getIndentEnd()
यह फ़ंक्शन, इंडेंटेशन के आखिर में मौजूद पॉइंट को वापस लाता है.
वापसी का टिकट
Number|null — यह इंडेंटेशन के आखिर में मौजूद पॉइंट की संख्या होती है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getIndentFirstLine()
यह पहली लाइन के इंडेंटेशन को पॉइंट में दिखाता है.
वापसी का टिकट
Number|null — पहली लाइन का इंडेंटेशन, पॉइंट में
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getIndentStart()
इससे इंडेंटेशन की शुरुआती जगह मिलती है.
वापसी का टिकट
Number|null — यह स्टार्ट इंडेंटेशन है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getLineSpacing()
यह लाइन स्पेसिंग को पॉइंट में दिखाता है.
वापसी का टिकट
Number|null — लाइन के बीच की दूरी, पॉइंट में
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getLinkUrl()
यह कुकी, लिंक का यूआरएल वापस पाती है.
वापसी का टिकट
String|null — लिंक का यूआरएल या अगर एलिमेंट में इस एट्रिब्यूट के लिए कई वैल्यू शामिल हैं, तो null
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getNextSibling()
यह एलिमेंट के अगले सिबलिंग एलिमेंट को वापस लाता है.
अगले सिबलिंग का पैरंट वही होता है जो मौजूदा एलिमेंट का होता है. साथ ही, यह मौजूदा एलिमेंट के बाद आता है.
वापसी का टिकट
Element|null — अगला सिबलिंग एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getNumChildren()
इससे बच्चों की संख्या मिलती है.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Log the number of elements in the tab. Logger.log(`There are ${body.getNumChildren()} elements in the tab's body.`);
वापसी का टिकट
Integer — बच्चों की संख्या.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
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
getPositionedImage(id)
इमेज के आईडी के हिसाब से, PositionedImage मिलता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
id | String | इमेज आईडी |
वापसी का टिकट
PositionedImage — पोज़िशन की गई इमेज
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getPositionedImages()
पैराग्राफ़ से जुड़े सभी PositionedImage ऑब्जेक्ट मिलते हैं.
वापसी का टिकट
PositionedImage[] — यह ऐसी इमेज की सूची होती है जिन्हें किसी जगह पर रखा गया है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
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
getSpacingAfter()
यह फ़ंक्शन, एलिमेंट के बाद की जगह की जानकारी पॉइंट में दिखाता है.
वापसी का टिकट
Number|null — एलिमेंट के बाद की रिक्ति, पॉइंट में
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getSpacingBefore()
यह फ़ंक्शन, एलिमेंट के पहले की स्पेस को पॉइंट में दिखाता है.
वापसी का टिकट
Number|null — एलिमेंट से पहले की स्पेस, पॉइंट में
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getText()
यह फ़ंक्शन, एलिमेंट के कॉन्टेंट को टेक्स्ट स्ट्रिंग के तौर पर वापस लाता है.
वापसी का टिकट
String — एलिमेंट का कॉन्टेंट, टेक्स्ट स्ट्रिंग के तौर पर
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getTextAlignment()
टेक्स्ट अलाइनमेंट की जानकारी मिलती है. अलाइनमेंट के लिए ये विकल्प उपलब्ध हैं: DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT, और DocumentApp.TextAlignment.SUPERSCRIPT.
वापसी का टिकट
TextAlignment|null — टेक्स्ट अलाइनमेंट का टाइप या null अगर टेक्स्ट में कई तरह के टेक्स्ट अलाइनमेंट शामिल हैं या टेक्स्ट अलाइनमेंट कभी सेट नहीं किया गया है
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
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
insertHorizontalRule(childIndex)
यह फ़ंक्शन, तय किए गए इंडेक्स पर HorizontalRule बनाता है और उसे डालता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Integer | वह इंडेक्स जहां एलिमेंट को डाला जाना है |
वापसी का टिकट
HorizontalRule — नया हॉरिज़ॉन्टल रूल एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertInlineImage(childIndex, image)
यह फ़ंक्शन, दी गई इमेज के ब्यौरे से एक नया InlineImage बनाता है और उसे दिए गए इंडेक्स पर डालता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Integer | वह इंडेक्स जहां एलिमेंट को डाला जाना है |
image | Blob | इमेज का डेटा |
वापसी का टिकट
InlineImage — जोड़ी गई इनलाइन इमेज एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertInlineImage(childIndex, image)
यह फ़ंक्शन, दिए गए इंडेक्स पर InlineImage को शामिल करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Integer | वह इंडेक्स जहां एलिमेंट को डाला जाना है |
image | Inline | इमेज का डेटा |
वापसी का टिकट
InlineImage — जोड़ी गई इनलाइन इमेज एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertPageBreak(childIndex)
यह तय किए गए इंडेक्स पर, नया PageBreak बनाता है और उसे डालता है.
ध्यान दें: ऐसा हो सकता है कि PageBreaks, TableCells में शामिल न हो.
अगर मौजूदा एलिमेंट, टेबल सेल में शामिल है, तो एक अपवाद दिखेगा.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Integer | वह इंडेक्स जहां एलिमेंट को डाला जाना है |
वापसी का टिकट
PageBreak — नया पेज ब्रेक एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertPageBreak(childIndex, pageBreak)
यह फ़ंक्शन, दिए गए इंडेक्स पर PageBreak को शामिल करता है.
ध्यान दें: ऐसा हो सकता है कि PageBreaks, TableCells में शामिल न हो.
अगर मौजूदा एलिमेंट, टेबल सेल में शामिल है, तो एक अपवाद दिखेगा.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Integer | वह इंडेक्स जहां एलिमेंट को डाला जाना है |
page | Page | पेज ब्रेक को शामिल करने के लिए |
वापसी का टिकट
PageBreak — डाला गया पेज ब्रेक एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertText(childIndex, text)
यह तय किए गए इंडेक्स पर, नया टेक्स्ट एलिमेंट बनाता है और उसे जोड़ता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Integer | वह इंडेक्स जहां एलिमेंट को डाला जाना है |
text | String | टेक्स्ट कॉन्टेंट |
वापसी का टिकट
Text — नया टेक्स्ट एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertText(childIndex, text)
यह दिए गए Text एलिमेंट को बताए गए इंडेक्स पर, बताए गए टेक्स्ट कॉन्टेंट के साथ डालता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Integer | वह इंडेक्स जहां एलिमेंट को डाला जाना है |
text | Text | टेक्स्ट एलिमेंट को शामिल करना है |
वापसी का टिकट
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
isLeftToRight()
यह कुकी, बाएं से दाएं की सेटिंग को वापस लाती है.
वापसी का टिकट
Boolean|null — बाएं से दाएं की सेटिंग
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
merge()
इस विकल्प का इस्तेमाल करके, एलिमेंट को उसी तरह के पिछले सिबलिंग के साथ मर्ज किया जाता है.
सिर्फ़ एक ही ElementType के एलिमेंट मर्ज किए जा सकते हैं. मौजूदा एलिमेंट में मौजूद सभी चाइल्ड एलिमेंट को, पहले वाले सिबलिंग एलिमेंट में ले जाया जाता है.
मौजूदा एलिमेंट को दस्तावेज़ से हटा दिया जाता है.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Example 1: Merge paragraphs // Append two paragraphs to the document's active tab. const par1 = body.appendParagraph('Paragraph 1.'); const par2 = body.appendParagraph('Paragraph 2.'); // Merge the newly added paragraphs into a single paragraph. par2.merge(); // Example 2: Merge table cells // Create a two-dimensional array containing the table's cell contents. const cells = [ ['Row 1, Cell 1', 'Row 1, Cell 2'], ['Row 2, Cell 1', 'Row 2, Cell 2'], ]; // Build a table from the array. const table = body.appendTable(cells); // Get the first row in the table. const row = table.getRow(0); // Get the two cells in this row. const cell1 = row.getCell(0); const cell2 = row.getCell(1); // Merge the current cell into its preceding sibling element. const merged = cell2.merge();
वापसी का टिकट
Paragraph|null — मर्ज किया गया एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
removeChild(child)
यह फ़ंक्शन, बताए गए चाइल्ड एलिमेंट को हटाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
child | Element | हटाया जाने वाला चाइल्ड एलिमेंट |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
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(); }
वापसी का टिकट
Paragraph|null — हटाया गया एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
removePositionedImage(id)
यह इमेज के आईडी के हिसाब से, PositionedImage को हटाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
id | String | इमेज आईडी |
वापसी का टिकट
Boolean — इससे पता चलता है कि बताई गई इमेज को हटाया गया है या नहीं
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
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
setAlignment(alignment)
HorizontalAlignment को सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
alignment | Horizontal | हॉरिज़ॉन्टल अलाइनमेंट |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
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 | एलिमेंट के एट्रिब्यूट. |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट.
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setHeading(heading)
ParagraphHeading को सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
heading | Paragraph | हेडिंग |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setIndentEnd(indentEnd)
यह विकल्प, इंडेंटेशन के खत्म होने की जगह को पॉइंट में सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
indent | Number | पॉइंट में एंड इंडेंटेशन |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setIndentFirstLine(indentFirstLine)
यह विकल्प, पहली लाइन के इंडेंट को पॉइंट में सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
indent | Number | पहली लाइन का इंडेंटेशन, पॉइंट में |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setIndentStart(indentStart)
यह विकल्प, इंडेंटेशन की शुरुआती जगह को पॉइंट में सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
indent | Number | शुरुआती इंडेंटेशन, पॉइंट में |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setLeftToRight(leftToRight)
यह कुकी, बाएं से दाएं की सेटिंग सेट करती है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
left | Boolean | बाएं से दाएं की सेटिंग |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setLineSpacing(multiplier)
लाइन स्पेसिंग सेट करता है. यह एक ऐसी संख्या होती है जिससे पता चलता है कि स्पेसिंग के लिए कितनी लाइनों का इस्तेमाल करना है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
multiplier | Number | लाइनों की संख्या |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setLinkUrl(url)
यह लिंक का यूआरएल सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
url | String | लिंक का यूआरएल |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setSpacingAfter(spacingAfter)
यह विकल्प, एलिमेंट के बाद की जगह को पॉइंट में सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
spacing | Number | एलिमेंट के बाद की रिक्ति, पॉइंट में |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setSpacingBefore(spacingBefore)
यह विकल्प, एलिमेंट के पहले की स्पेस को पॉइंट में सेट करता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
spacing | Number | एलिमेंट से पहले की स्पेस, पॉइंट में |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setText(text)
इस विकल्प से, पैराग्राफ़ के कॉन्टेंट को टेक्स्ट के तौर पर सेट किया जाता है.
ध्यान दें: मौजूदा कॉन्टेंट मिटा दिया जाता है.
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
text | String | नया टेक्स्ट कॉन्टेंट |
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setTextAlignment(textAlignment)
इससे टेक्स्ट अलाइनमेंट सेट किया जाता है. अलाइनमेंट के लिए ये विकल्प उपलब्ध हैं: DocumentApp.TextAlignment.NORMAL, DocumentApp.TextAlignment.SUBSCRIPT, और DocumentApp.TextAlignment.SUPERSCRIPT.
// Make the entire first paragraph in the active tab be superscript. const documentTab = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab(); const text = documentTab.getBody().getParagraphs()[0].editAsText(); text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);
पैरामीटर
| नाम | टाइप | ब्यौरा |
|---|---|---|
text | Text | टेक्स्ट अलाइनमेंट का टाइप |
वापसी का टिकट
Paragraph — मौजूदा एलिमेंट
अनुमति देना
इस तरीके का इस्तेमाल करने वाली स्क्रिप्ट के लिए, इनमें से एक या उससे ज़्यादा स्कोप के साथ अनुमति लेना ज़रूरी है:
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents