Class ListItem

ListItem

목록 항목을 나타내는 요소입니다. ListItem은(는) 연결된 Paragraph 목록 ID로 구성됩니다. ListItem에는 Equation, Footnote, HorizontalRule, InlineDrawing, InlineImage, PageBreak, Text가 포함될 수 있습니다. 요소 문서 구조에 대한 자세한 내용은 Google Docs 확장 가이드를 참조하세요.

ListItems에는 줄바꿈 문자가 포함될 수 없습니다. 줄바꿈 문자('\n')는 줄바꿈 문자('\r')로 변환됨

목록 ID가 동일한 ListItems는 동일한 목록에 속하며 그에 따라 번호가 매겨집니다. 지정된 목록의 ListItems가 탭에서 인접하지 않아도 되거나 같은 상위 요소로 구성됩니다. 동일한 목록에 속하는 두 개의 항목이 탭의 어느 곳에나 존재할 수 있지만 다음 예에서 볼 수 있듯이 연속으로 번호 매기기가 계속 유지됩니다.

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Append a new list item to the body.
var 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.
var item2 = body.appendListItem('Item 2');
item2.setListId(item1);

메서드

메서드반환 유형간략한 설명
addPositionedImage(image)PositionedImage지정된 이미지 blob에서 새 PositionedImage를 만들고 삽입합니다.
appendHorizontalRule()HorizontalRuleHorizontalRule를 만들고 추가합니다.
appendInlineImage(image)InlineImage지정된 이미지 blob에서 새 InlineImage를 만들고 추가합니다.
appendInlineImage(image)InlineImage지정된 InlineImage를 추가합니다.
appendPageBreak()PageBreakPageBreak를 만들고 추가합니다.
appendPageBreak(pageBreak)PageBreak지정된 PageBreak를 추가합니다.
appendText(text)Text지정된 콘텐츠로 새 Text 요소를 만들고 추가합니다.
appendText(text)Text지정된 Text 요소를 추가합니다.
clear()ListItem요소의 콘텐츠를 지웁니다.
copy()ListItem현재 요소의 분리된 전체 사본을 반환합니다.
editAsText()Text수정을 위해 현재 요소의 Text 버전을 가져옵니다.
findElement(elementType)RangeElement요소의 콘텐츠에서 지정된 유형의 하위 요소를 검색합니다.
findElement(elementType, from)RangeElement요소의 콘텐츠를 검색하여 지정된 유형의 하위 요소를 찾습니다. 이때 RangeElement로 지정되었습니다.
findText(searchPattern)RangeElement정규 표현식을 사용하여 요소의 콘텐츠에서 지정된 텍스트 패턴을 검색합니다.
findText(searchPattern, from)RangeElement요소의 콘텐츠에서 지정된 텍스트 패턴(지정된 표시됩니다.
getAlignment()HorizontalAlignmentHorizontalAlignment를 검색합니다.
getAttributes()Object요소의 속성을 검색합니다.
getChild(childIndex)Element지정된 하위 색인에서 하위 요소를 검색합니다.
getChildIndex(child)Integer지정된 하위 요소의 하위 색인을 검색합니다.
getGlyphType()GlyphType목록 항목의 GlyphType를 검색합니다.
getHeading()ParagraphHeadingParagraphHeading를 검색합니다.
getIndentEnd()Number끝 들여쓰기를 포인트 단위로 검색합니다.
getIndentFirstLine()Number첫 줄 들여쓰기를 포인트 단위로 검색합니다.
getIndentStart()Number시작 들여쓰기를 검색합니다.
getLineSpacing()Number줄 간격을 포인트 단위로 검색합니다.
getLinkUrl()String링크 URL을 검색합니다.
getListId()String목록 ID를 검색합니다.
getNestingLevel()Integer목록 항목의 중첩 수준을 검색합니다.
getNextSibling()Element요소의 다음 동위 요소를 검색합니다.
getNumChildren()Integer하위 요소의 수를 검색합니다.
getParent()ContainerElement요소의 상위 요소를 검색합니다.
getPositionedImage(id)PositionedImage이미지의 ID를 사용하여 PositionedImage를 가져옵니다.
getPositionedImages()PositionedImage[]단락에 고정된 모든 PositionedImage 객체를 가져옵니다.
getPreviousSibling()Element요소의 이전 동위 요소를 검색합니다.
getSpacingAfter()Number요소 뒤의 간격(포인트)을 검색합니다.
getSpacingBefore()Number요소 앞 간격(포인트)을 검색합니다.
getText()String요소의 콘텐츠를 텍스트 문자열로 검색합니다.
getTextAlignment()TextAlignment텍스트 정렬을 가져옵니다.
getType()ElementType요소의 ElementType를 검색합니다.
insertHorizontalRule(childIndex)HorizontalRule지정된 색인에 HorizontalRule를 만들고 삽입합니다.
insertInlineImage(childIndex, image)InlineImage지정된 이미지 blob에서 지정된 위치에 새 InlineImage를 만들고 삽입합니다. 색인
insertInlineImage(childIndex, image)InlineImage지정된 색인에 지정된 InlineImage를 삽입합니다.
insertPageBreak(childIndex)PageBreak지정된 색인에 새 PageBreak를 만들고 삽입합니다.
insertPageBreak(childIndex, pageBreak)PageBreak지정된 색인에 지정된 PageBreak를 삽입합니다.
insertText(childIndex, text)Text지정된 색인에 새 텍스트 요소를 만들어 삽입합니다.
insertText(childIndex, text)Text지정된 색인에 지정된 Text 요소를 지정된 텍스트와 함께 삽입합니다. 있습니다.
isAtDocumentEnd()Boolean요소가 Document 끝에 있는지 확인합니다.
isLeftToRight()Boolean왼쪽에서 오른쪽으로 설정을 검색합니다.
merge()ListItem요소를 동일한 유형의 앞의 동위 요소와 병합합니다.
removeChild(child)ListItem지정된 하위 요소를 삭제합니다.
removeFromParent()ListItem상위 항목에서 요소를 삭제합니다.
removePositionedImage(id)Boolean이미지의 ID를 사용하여 PositionedImage를 삭제합니다.
replaceText(searchPattern, replacement)Element정규식을 사용하여 지정된 텍스트 패턴과 일치하는 모든 항목을 지정된 대체 문자열로 바꿉니다. 식을 사용할 수 있습니다.
setAlignment(alignment)ListItemHorizontalAlignment를 설정합니다.
setAttributes(attributes)ListItem요소의 속성을 설정합니다.
setGlyphType(glyphType)ListItem목록 항목의 GlyphType를 설정합니다.
setHeading(heading)ListItemParagraphHeading를 설정합니다.
setIndentEnd(indentEnd)ListItem끝 들여쓰기를 포인트 단위로 설정합니다.
setIndentFirstLine(indentFirstLine)ListItem첫 줄 들여쓰기를 포인트 단위로 설정합니다.
setIndentStart(indentStart)ListItem시작 들여쓰기를 포인트 단위로 설정합니다.
setLeftToRight(leftToRight)ListItem왼쪽에서 오른쪽으로 설정을 지정합니다.
setLineSpacing(multiplier)ListItem줄 간격을 간격에 사용할 줄 수를 나타내는 수량으로 설정합니다.
setLinkUrl(url)ListItem링크 URL을 설정합니다.
setListId(listItem)ListItem목록 ID를 설정합니다.
setNestingLevel(nestingLevel)ListItem목록 항목의 중첩 수준을 설정합니다.
setSpacingAfter(spacingAfter)ListItem요소 뒤의 간격을 포인트 단위로 설정합니다.
setSpacingBefore(spacingBefore)ListItem요소 앞 간격을 포인트 단위로 설정합니다.
setText(text)void목록 항목의 콘텐츠를 텍스트로 설정합니다.
setTextAlignment(textAlignment)ListItem텍스트 정렬을 설정합니다.

자세한 문서

addPositionedImage(image)

지정된 이미지 blob에서 새 PositionedImage를 만들고 삽입합니다.

매개변수

이름유형설명
imageBlobSource이미지 데이터

리턴

PositionedImage: 새로 배치된 이미지

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

appendHorizontalRule()

HorizontalRule를 만들고 추가합니다.

리턴

HorizontalRule: 새 가로 규칙

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

appendInlineImage(image)

지정된 이미지 blob에서 새 InlineImage를 만들고 추가합니다.

매개변수

이름유형설명
imageBlobSource이미지 데이터

리턴

InlineImage - 추가된 이미지

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

appendInlineImage(image)

지정된 InlineImage를 추가합니다.

매개변수

이름유형설명
imageInlineImage이미지 데이터

리턴

InlineImage - 추가된 이미지

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

appendPageBreak()

PageBreak를 만들고 추가합니다.

참고: PageBreaksTableCells 내에 포함될 수 없습니다. 현재 요소가 표의 셀에 포함되어 있으면 예외가 발생합니다.

리턴

PageBreak: 새 페이지 나누기 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

appendPageBreak(pageBreak)

지정된 PageBreak를 추가합니다.

참고: PageBreaksTableCells 내에 포함될 수 없습니다. 현재 요소가 표의 셀에 포함되어 있으면 예외가 발생합니다.

매개변수

이름유형설명
pageBreakPageBreak추가할 페이지 나누기

리턴

PageBreak - 추가된 페이지 나누기 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

appendText(text)

지정된 콘텐츠로 새 Text 요소를 만들고 추가합니다.

매개변수

이름유형설명
textString텍스트 콘텐츠

리턴

Text: 새 텍스트 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

appendText(text)

지정된 Text 요소를 추가합니다.

매개변수

이름유형설명
textText추가할 텍스트 요소

리턴

Text - 추가된 텍스트 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

clear()

요소의 콘텐츠를 지웁니다.

리턴

ListItem - 현재 요소입니다.


copy()

현재 요소의 분리된 전체 사본을 반환합니다.

요소에 있는 모든 하위 요소도 복사됩니다. 새 요소에는 있습니다.

리턴

ListItem - 새 사본입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

editAsText()

수정을 위해 현재 요소의 Text 버전을 가져옵니다.

요소 콘텐츠를 서식 있는 텍스트로 조작하는 데 editAsText를 사용합니다. editAsText 모드는 텍스트가 아닌 요소 (예: InlineImageHorizontalRule)를 무시합니다.

삭제된 텍스트 범위 내에 완전히 포함된 하위 요소는 요소에서 삭제됩니다.

var 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)

요소의 콘텐츠에서 지정된 유형의 하위 요소를 검색합니다.

매개변수

이름유형설명
elementTypeElementType검색할 요소의 유형입니다.

리턴

RangeElement - 검색 요소의 위치를 나타내는 검색 결과입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

findElement(elementType, from)

요소의 콘텐츠를 검색하여 지정된 유형의 하위 요소를 찾습니다. 이때 RangeElement로 지정되었습니다.

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Define the search parameters.
var searchType = DocumentApp.ElementType.PARAGRAPH;
var searchHeading = DocumentApp.ParagraphHeading.HEADING1;
var searchResult = null;

// Search until the paragraph is found.
while (searchResult = body.findElement(searchType, searchResult)) {
  var par = searchResult.getElement().asParagraph();
  if (par.getHeading() == searchHeading) {
    // Found one, update and stop.
    par.setText('This is the first header.');
    return;
  }
}

매개변수

이름유형설명
elementTypeElementType검색할 요소의 유형입니다.
fromRangeElement검색할 검색 결과입니다.

리턴

RangeElement - 검색 요소의 다음 위치를 나타내는 검색 결과입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

findText(searchPattern)

정규 표현식을 사용하여 요소의 콘텐츠에서 지정된 텍스트 패턴을 검색합니다.

JavaScript 정규 표현식 기능의 하위 집합은 완전히 지원되지 않습니다. 예를 들면 다음과 같습니다. 그룹 및 모드 수정자를 캡처합니다.

제공된 정규 표현식 패턴이 각 텍스트 블록과 독립적으로 일치됩니다. .

매개변수

이름유형설명
searchPatternString검색할 패턴

리턴

RangeElement — 검색 텍스트의 위치를 나타내는 검색 결과, 또는 없는 경우 null 일치

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

findText(searchPattern, from)

요소의 콘텐츠에서 지정된 텍스트 패턴(지정된 표시됩니다.

JavaScript 정규 표현식 기능의 하위 집합은 완전히 지원되지 않습니다. 예를 들면 다음과 같습니다. 그룹 및 모드 수정자를 캡처합니다.

제공된 정규 표현식 패턴이 각 텍스트 블록과 독립적으로 일치됩니다. .

매개변수

이름유형설명
searchPatternString검색할 패턴
fromRangeElement검색할 검색결과

리턴

RangeElement: 검색 텍스트의 다음 위치를 나타내는 검색 결과, 또는 없는 경우 null입니다. 일치

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getAlignment()

HorizontalAlignment를 검색합니다.

리턴

HorizontalAlignment: 정렬

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getAttributes()

요소의 속성을 검색합니다.

결과는 유효한 각 요소 속성에 대한 속성을 포함하는 객체이며, 여기서 각 요소는 속성 이름은 DocumentApp.Attribute 열거형의 항목에 해당합니다.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.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

getChild(childIndex)

지정된 하위 색인에서 하위 요소를 검색합니다.

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Obtain the first element in the tab.
var 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.");
}

매개변수

이름유형설명
childIndexInteger검색할 하위 요소의 색인입니다.

리턴

Element - 지정된 색인의 하위 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getChildIndex(child)

지정된 하위 요소의 하위 색인을 검색합니다.

매개변수

이름유형설명
childElement색인을 검색할 하위 요소입니다.

리턴

Integer - 하위 색인입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getGlyphType()

목록 항목의 GlyphType를 검색합니다.

리턴

GlyphType: 글리프 유형

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getHeading()

ParagraphHeading를 검색합니다.

리턴

ParagraphHeading: 제목

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getIndentEnd()

끝 들여쓰기를 포인트 단위로 검색합니다.

리턴

Number: 끝 들여쓰기(포인트)

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getIndentFirstLine()

첫 줄 들여쓰기를 포인트 단위로 검색합니다.

리턴

Number: 첫 줄 들여쓰기(포인트)

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getIndentStart()

시작 들여쓰기를 검색합니다.

리턴

Number: 시작 들여쓰기

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getLineSpacing()

줄 간격을 포인트 단위로 검색합니다.

리턴

Number: 줄 간격(포인트)

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getLinkUrl()

링크 URL을 검색합니다.

리턴

String — 링크 URL 또는 요소에 이 속성의 값이 여러 개 포함된 경우 null

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getListId()

목록 ID를 검색합니다.

리턴

String: 목록 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()

요소의 다음 동위 요소를 검색합니다.

다음 동위 요소는 동일한 상위 요소를 가지며 현재 요소를 따릅니다.

리턴

Element - 다음 동위 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getNumChildren()

하위 요소 수를 검색합니다.

var 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 - 상위 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getPositionedImage(id)

이미지의 ID를 사용하여 PositionedImage를 가져옵니다.

매개변수

이름유형설명
idString이미지 ID

리턴

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 - 이전 동위 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getSpacingAfter()

요소 뒤의 간격(포인트)을 검색합니다.

리턴

Number: 요소 뒤 간격(포인트)

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getSpacingBefore()

요소 앞 간격(포인트)을 검색합니다.

리턴

Number: 요소 앞 간격(포인트)

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • 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(텍스트에 여러 유형의 텍스트가 포함된 경우) 텍스트 정렬이 설정되지 않은 경우

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

getType()

요소의 ElementType를 검색합니다.

getType()를 사용하여 지정된 요소의 정확한 유형을 확인합니다.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.getBody();

// Obtain the first element in the active tab's 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

insertHorizontalRule(childIndex)

지정된 색인에 HorizontalRule를 만들고 삽입합니다.

매개변수

이름유형설명
childIndexInteger요소를 삽입할 색인

리턴

HorizontalRule: 새 가로 규칙 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

insertInlineImage(childIndex, image)

지정된 이미지 blob에서 지정된 위치에 새 InlineImage를 만들고 삽입합니다. 색인

매개변수

이름유형설명
childIndexInteger요소를 삽입할 색인
imageBlobSource이미지 데이터

리턴

InlineImage: 삽입된 인라인 이미지 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

insertInlineImage(childIndex, image)

지정된 색인에 지정된 InlineImage를 삽입합니다.

매개변수

이름유형설명
childIndexInteger요소를 삽입할 색인
imageInlineImage이미지 데이터

리턴

InlineImage: 삽입된 인라인 이미지 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

insertPageBreak(childIndex)

지정된 색인에 새 PageBreak를 만들고 삽입합니다.

참고: PageBreaksTableCells 내에 포함될 수 없습니다. 현재 요소가 표의 셀에 포함되어 있으면 예외가 발생합니다.

매개변수

이름유형설명
childIndexInteger요소를 삽입할 색인

리턴

PageBreak: 새 페이지 나누기 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

insertPageBreak(childIndex, pageBreak)

지정된 색인에 지정된 PageBreak를 삽입합니다.

참고: PageBreaksTableCells 내에 포함될 수 없습니다. 현재 요소가 표의 셀에 포함되어 있으면 예외가 발생합니다.

매개변수

이름유형설명
childIndexInteger요소를 삽입할 색인
pageBreakPageBreak인코더-디코더 아키텍처를

리턴

PageBreak - 삽입된 페이지 나누기 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

insertText(childIndex, text)

지정된 색인에 새 텍스트 요소를 만들어 삽입합니다.

매개변수

이름유형설명
childIndexInteger요소를 삽입할 색인
textString텍스트 콘텐츠

리턴

Text: 새 텍스트 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

insertText(childIndex, text)

지정된 색인에 지정된 Text 요소를 지정된 텍스트와 함께 삽입합니다. 있습니다.

매개변수

이름유형설명
childIndexInteger요소를 삽입할 색인
textText삽입할 텍스트 요소

리턴

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: 왼쪽에서 오른쪽 설정

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

merge()

요소를 동일한 유형의 앞의 동위 요소와 병합합니다.

동일한 ElementType의 요소만 병합할 수 있습니다. 현재 요소가 이전 동위 요소로 이동합니다.

현재 요소가 문서에서 삭제됩니다.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.getBody();

// Example 1: Merge paragraphs
// Append two paragraphs to the document's active tab.
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();

리턴

ListItem - 병합된 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

removeChild(child)

지정된 하위 요소를 삭제합니다.

매개변수

이름유형설명
childElement삭제할 하위 요소

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

removeFromParent()

상위 항목에서 요소를 삭제합니다.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab()
var body = documentTab.getBody();

// Remove all images in the active tab's body.
var imgs = body.getImages();
for (var i = 0; i < imgs.length; i++) {
  imgs[i].removeFromParent();
}

리턴

ListItem - 삭제된 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

removePositionedImage(id)

이미지의 ID를 사용하여 PositionedImage를 삭제합니다.

매개변수

이름유형설명
idString

리턴

Boolean — 지정된 이미지가 삭제되었는지 여부

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

replaceText(searchPattern, replacement)

정규식을 사용하여 지정된 텍스트 패턴과 일치하는 모든 항목을 지정된 대체 문자열로 바꿉니다. 식을 사용할 수 있습니다.

검색 패턴은 JavaScript 정규 표현식 객체가 아닌 문자열로 전달됩니다. 따라서 패턴에서 백슬래시를 이스케이프 처리해야 합니다.

이 방법은 Google의 RE2 일반 표현식 라이브러리를 사용할 수 있습니다. 이 API는 지원되는 구문을 제한합니다.

제공된 정규 표현식 패턴이 각 텍스트 블록과 독립적으로 일치됩니다. .

var body = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab().getBody();

// Clear the text surrounding "Apps Script", with or without text.
body.replaceText("^.*Apps ?Script.*$", "Apps Script");

매개변수

이름유형설명
searchPatternString검색할 정규식 패턴
replacementString대체로 사용할 텍스트

리턴

Element: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setAlignment(alignment)

HorizontalAlignment를 설정합니다.

매개변수

이름유형설명
alignmentHorizontalAlignment가로 정렬

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setAttributes(attributes)

요소의 속성을 설정합니다.

지정된 속성 매개변수는 각 속성 이름이 항목인 객체여야 합니다. DocumentApp.Attribute 열거형이며 각 속성 값은 새 값입니다. 적용됩니다.

var doc = DocumentApp.getActiveDocument();
var documentTab = doc.getActiveTab().asDocumentTab();
var body = documentTab.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);

매개변수

이름유형설명
attributesObject요소의 속성입니다.

리턴

ListItem - 현재 요소입니다.

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setGlyphType(glyphType)

목록 항목의 GlyphType를 설정합니다.

매개변수

이름유형설명
glyphTypeGlyphType글리프 유형

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setHeading(heading)

ParagraphHeading를 설정합니다.

매개변수

이름유형설명
headingParagraphHeading제목

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setIndentEnd(indentEnd)

끝 들여쓰기를 포인트 단위로 설정합니다.

매개변수

이름유형설명
indentEndNumber끝 들여쓰기 간격(포인트)

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setIndentFirstLine(indentFirstLine)

첫 줄 들여쓰기를 포인트 단위로 설정합니다.

매개변수

이름유형설명
indentFirstLineNumber첫 줄 들여쓰기(포인트)

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setIndentStart(indentStart)

시작 들여쓰기를 포인트 단위로 설정합니다.

매개변수

이름유형설명
indentStartNumber시작 들여쓰기 간격(포인트)

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setLeftToRight(leftToRight)

왼쪽에서 오른쪽으로 설정을 지정합니다.

매개변수

이름유형설명
leftToRightBoolean왼쪽에서 오른쪽으로 설정

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setLineSpacing(multiplier)

줄 간격을 간격에 사용할 줄 수를 나타내는 수량으로 설정합니다.

매개변수

이름유형설명
multiplierNumber줄 수

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setLinkUrl(url)

링크 URL을 설정합니다.

매개변수

이름유형설명
urlString링크 URL

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setListId(listItem)

목록 ID를 설정합니다.

지정된 ListItem에 대해 목록 ID가 동일한 값으로 설정됩니다. 두 ListItems는 동일한 목록의 구성원으로 처리됩니다.

매개변수

이름유형설명
listItemListItem사용할 목록 ID가 있는 목록 항목

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setNestingLevel(nestingLevel)

목록 항목의 중첩 수준을 설정합니다.

기본적으로 목록 항목의 중첩 수준은 0입니다. 중첩 수준에 따라 글리프가 결정됩니다. 사용됩니다.

매개변수

이름유형설명
nestingLevelInteger중첩 수준

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setSpacingAfter(spacingAfter)

요소 뒤의 간격을 포인트 단위로 설정합니다.

매개변수

이름유형설명
spacingAfterNumber요소 뒤 간격(포인트)

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setSpacingBefore(spacingBefore)

요소 앞 간격을 포인트 단위로 설정합니다.

매개변수

이름유형설명
spacingBeforeNumber요소 앞 간격(포인트)

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents

setText(text)

목록 항목의 콘텐츠를 텍스트로 설정합니다.

참고: 기존 콘텐츠는 삭제됩니다.

매개변수

이름유형설명
textString새로운 텍스트 콘텐츠가

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • 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.
var documentTab = DocumentApp.getActiveDocument().getActiveTab().asDocumentTab();
var text = documentTab.getBody().getParagraphs()[0].editAsText();
text.setTextAlignment(DocumentApp.TextAlignment.SUPERSCRIPT);

매개변수

이름유형설명
textAlignmentTextAlignment적용할 텍스트 정렬 유형

리턴

ListItem: 현재 요소

승인

이 메서드를 사용하는 스크립트에는 다음 범위 중 하나 이상으로 승인이 필요합니다.

  • https://www.googleapis.com/auth/documents.currentonly
  • https://www.googleapis.com/auth/documents