목록 항목을 나타내는 요소입니다. List는 목록 ID와 연결된 Paragraph입니다. List에는 Equation, Footnote, Horizontal, Inline, Inline, Page, Text 요소가 포함될 수 있습니다. 문서 구조에 관한 자세한 내용은 Google Docs 확장 가이드를 참고하세요.
List에는 줄바꿈 문자가 포함될 수 없습니다. 줄바꿈 문자 ('\n')는 줄바꿈 문자 ('\r')로 변환됩니다.
목록 ID가 동일한 List는 동일한 목록에 속하며 그에 따라 번호가 매겨집니다.
특정 목록의 List이 탭에서 인접하거나 동일한 상위 요소를 가질 필요는 없습니다. 동일한 목록에 속하는 두 항목은 다음 예와 같이 연속 번호 매기기를 유지하면서 탭의 어느 곳에나 있을 수 있습니다.
const body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody(); // Append a new list item to the body. const item1 = body.appendListItem('Item 1'); // Log the new list item's list ID. Logger.log(item1.getListId()); // Append a table after the list item. body.appendTable([['Cell 1', 'Cell 2']]); // Append a second list item with the same list ID. The two items are treated as // the same list, despite not being consecutive. const item2 = body.appendListItem('Item 2'); item2.setListId(item1);
메서드
자세한 문서
addPositionedImage(image)
지정된 이미지 blob에서 새 Positioned를 만들어 삽입합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
image | Blob | 이미지 데이터 |
리턴
Positioned - 새로 배치된 이미지
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendHorizontalRule()
새 Horizontal를 만들어 추가합니다.
리턴
Horizontal - 새 가로줄
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendInlineImage(image)
지정된 이미지 blob에서 새 Inline를 만들어 추가합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
image | Blob | 이미지 데이터 |
리턴
Inline - 추가된 이미지
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendInlineImage(image)
지정된 Inline를 추가합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
image | Inline | 이미지 데이터 |
리턴
Inline - 추가된 이미지
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendPageBreak()
새 Page를 만들어 추가합니다.
참고: Page는 Table 내에 포함되지 않을 수 있습니다.
현재 요소가 표 셀에 포함된 경우 예외가 발생합니다.
리턴
Page - 새 페이지 나누기 요소
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendPageBreak(pageBreak)
지정된 Page를 추가합니다.
참고: Page는 Table 내에 포함되지 않을 수 있습니다.
현재 요소가 표 셀에 포함된 경우 예외가 발생합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
page | Page | 추가할 페이지 나누기 |
리턴
Page - 추가된 페이지 나누기 요소
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
appendText(text)
appendText(text)
clear()
copy()
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: 현재 요소의 텍스트 버전
findElement(elementType)
요소의 콘텐츠에서 지정된 유형의 하위 요소를 검색합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
element | Element | 검색할 요소의 유형입니다. |
리턴
Range - 검색 요소의 위치를 나타내는 검색 결과입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
findElement(elementType, from)
지정된 Range에서 시작하여 지정된 유형의 하위 요소를 요소의 콘텐츠에서 검색합니다.
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 | 검색할 검색 결과입니다. |
리턴
Range - 검색 요소의 다음 위치를 나타내는 검색 결과입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
findText(searchPattern)
정규 표현식을 사용하여 요소의 콘텐츠에서 지정된 텍스트 패턴을 검색합니다.
캡처 그룹, 모드 수정자 등 JavaScript 정규 표현식 기능의 일부는 완전히 지원되지 않습니다.
제공된 정규 표현식 패턴은 현재 요소에 포함된 각 텍스트 블록에 대해 독립적으로 일치합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
search | String | 검색할 패턴 |
리턴
Range - 검색 텍스트의 위치를 나타내는 검색 결과 또는 일치하는 항목이 없는 경우 null
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
findText(searchPattern, from)
지정된 검색 결과부터 시작하여 요소의 콘텐츠에서 지정된 텍스트 패턴을 검색합니다.
캡처 그룹, 모드 수정자 등 JavaScript 정규 표현식 기능의 일부는 완전히 지원되지 않습니다.
제공된 정규 표현식 패턴은 현재 요소에 포함된 각 텍스트 블록에 대해 독립적으로 일치합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
search | String | 검색할 패턴 |
from | Range | 검색할 검색 결과 |
리턴
Range - 검색 텍스트의 다음 위치를 나타내는 검색 결과입니다. 일치하는 항목이 없으면 null입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getAlignment()
Horizontal를 가져옵니다.
리턴
Horizontal - 정렬
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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
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)
getGlyphType()
getHeading()
Paragraph를 가져옵니다.
리턴
Paragraph - 제목
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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()
링크 URL을 가져옵니다.
리턴
String|null - 링크 URL입니다. 요소에 이 속성의 값이 여러 개 포함된 경우 null입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getListId()
목록 ID를 가져옵니다.
리턴
String|null: 목록 ID
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getNestingLevel()
목록 항목의 중첩 수준을 가져옵니다.
기본적으로 목록 항목의 중첩 수준은 0입니다. 중첩 수준은 목록 항목에서 사용되는 글리프를 결정합니다.
리턴
Integer - 중첩 수준
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getNextSibling()
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()
요소의 상위 요소를 가져옵니다.
상위 요소에 현재 요소가 포함되어 있습니다.
리턴
Container - 상위 요소입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getPositionedImage(id)
이미지 ID로 Positioned를 가져옵니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
id | String | 이미지 ID |
리턴
Positioned - 위치가 지정된 이미지
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getPositionedImages()
단락에 고정된 모든 Positioned 객체를 가져옵니다.
리턴
Positioned - 위치가 지정된 이미지 목록
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
getPreviousSibling()
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()
텍스트 정렬을 가져옵니다. 사용 가능한 정렬 유형은 Document, Document, Document입니다.
리턴
Text - 텍스트 정렬 유형 또는 텍스트에 여러 유형의 텍스트 정렬이 포함되어 있거나 텍스트 정렬이 설정된 적이 없는 경우 null
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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
insertHorizontalRule(childIndex)
지정된 색인에 Horizontal을 만들어 삽입합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
child | Integer | 요소를 삽입할 색인 |
리턴
Horizontal - 새로운 가로줄 요소
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertInlineImage(childIndex, image)
지정된 이미지 blob에서 지정된 색인에 새 Inline를 만들어 삽입합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
child | Integer | 요소를 삽입할 색인 |
image | Blob | 이미지 데이터 |
리턴
Inline - 삽입된 인라인 이미지 요소
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertInlineImage(childIndex, image)
지정된 색인에 지정된 Inline를 삽입합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
child | Integer | 요소를 삽입할 색인 |
image | Inline | 이미지 데이터 |
리턴
Inline - 삽입된 인라인 이미지 요소
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertPageBreak(childIndex)
지정된 색인에 새 Page를 만들어 삽입합니다.
참고: Page는 Table 내에 포함되지 않을 수 있습니다.
현재 요소가 표 셀에 포함된 경우 예외가 발생합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
child | Integer | 요소를 삽입할 색인 |
리턴
Page - 새 페이지 나누기 요소
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertPageBreak(childIndex, pageBreak)
지정된 색인에 지정된 Page를 삽입합니다.
참고: Page는 Table 내에 포함되지 않을 수 있습니다.
현재 요소가 표 셀에 포함된 경우 예외가 발생합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
child | Integer | 요소를 삽입할 색인 |
page | Page | 삽입할 페이지 나누기 |
리턴
Page - 삽입된 페이지 나누기 요소
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
insertText(childIndex, text)
insertText(childIndex, text)
isAtDocumentEnd()
isLeftToRight()
왼쪽에서 오른쪽으로 설정 값을 가져옵니다.
리턴
Boolean|null - 왼쪽에서 오른쪽 설정
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
merge()
요소를 동일한 유형의 이전 형제와 병합합니다.
동일한 Element의 요소만 병합할 수 있습니다. 현재 요소에 포함된 하위 요소는 이전 형제 요소로 이동됩니다.
현재 요소가 문서에서 삭제됩니다.
const doc = DocumentApp.getActiveDocument(); const documentTab = doc.getActiveTab().asDocumentTab(); const body = documentTab.getBody(); // Example 1: Merge paragraphs // Append two paragraphs to the document's active tab. const par1 = body.appendParagraph('Paragraph 1.'); const par2 = body.appendParagraph('Paragraph 2.'); // Merge the newly added paragraphs into a single paragraph. par2.merge(); // Example 2: Merge table cells // Create a two-dimensional array containing the table's cell contents. const cells = [ ['Row 1, Cell 1', 'Row 1, Cell 2'], ['Row 2, Cell 1', 'Row 2, Cell 2'], ]; // Build a table from the array. const table = body.appendTable(cells); // Get the first row in the table. const row = table.getRow(0); // Get the two cells in this row. const cell1 = row.getCell(0); const cell2 = row.getCell(1); // Merge the current cell into its preceding sibling element. const merged = cell2.merge();
리턴
List - 병합된 요소입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
removeChild(child)
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(); }
리턴
List - 삭제된 요소입니다.
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
removePositionedImage(id)
이미지의 ID로 Positioned를 삭제합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
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)
Horizontal를 설정합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
alignment | Horizontal | 가로 정렬 |
리턴
List - 현재 요소
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 | 요소의 속성입니다. |
리턴
List - 현재 요소
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setGlyphType(glyphType)
setHeading(heading)
Paragraph를 설정합니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
heading | Paragraph | 제목 |
리턴
List - 현재 요소
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents
setIndentEnd(indentEnd)
setIndentFirstLine(indentFirstLine)
setIndentStart(indentStart)
setLeftToRight(leftToRight)
setLineSpacing(multiplier)
setLinkUrl(url)
setListId(listItem)
setNestingLevel(nestingLevel)
setSpacingAfter(spacingAfter)
setSpacingBefore(spacingBefore)
setText(text)
목록 항목의 콘텐츠를 텍스트로 설정합니다.
참고: 기존 콘텐츠는 삭제됩니다.
매개변수
| 이름 | 유형 | 설명 |
|---|---|---|
text | String | 새 텍스트 콘텐츠 |
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
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 | 적용할 텍스트 정렬 유형 |
리턴
List - 현재 요소
승인
이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상의 승인이 필요합니다.
-
https://www.googleapis.com/auth/documents.currentonly -
https://www.googleapis.com/auth/documents