Google Slides
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
สร้างงานนำเสนอใหม่
function createPresentation() {
var presentation =
Slides.Presentations.create({"title": "MyNewPresentation"});
console.log("Created presentation with ID: " + presentation.presentationId);
}
สร้างสไลด์ใหม่
function createSlide(presentationId) {
// You can specify the ID to use for the slide, as long as it's unique.
var pageId = Utilities.getUuid();
var requests = [{
"createSlide": {
"objectId": pageId,
"insertionIndex": 1,
"slideLayoutReference": {
"predefinedLayout": "TITLE_AND_TWO_COLUMNS"
}
}
}];
var slide =
Slides.Presentations.batchUpdate({'requests': requests}, presentationId);
console.log("Created Slide with ID: " + slide.replies[0].createSlide.objectId);
}
อ่านรหัสออบเจ็กต์องค์ประกอบของหน้า
function readPageElementIds(presentationId, pageId) {
// You can use a field mask to limit the data the API retrieves
// in a get request, or what fields are updated in an batchUpdate.
var response = Slides.Presentations.Pages.get(
presentationId, pageId, {"fields": "pageElements.objectId"});
console.log(response);
}
เพิ่มช่องข้อความใหม่
function addTextBox(presentationId, pageId) {
// You can specify the ID to use for elements you create,
// as long as the ID is unique.
var pageElementId = Utilities.getUuid();
var requests = [{
"createShape": {
"objectId": pageElementId,
"shapeType": "TEXT_BOX",
"elementProperties": {
"pageObjectId": pageId,
"size": {
"width": {
"magnitude": 150,
"unit": "PT"
},
"height": {
"magnitude": 50,
"unit": "PT"
}
},
"transform": {
"scaleX": 1,
"scaleY": 1,
"translateX": 200,
"translateY": 100,
"unit": "PT"
}
}
}
}, {
"insertText": {
"objectId": pageElementId,
"text": "My Added Text Box",
"insertionIndex": 0
}
}];
var response =
Slides.Presentations.batchUpdate({'requests': requests}, presentationId);
console.log("Created Textbox with ID: " +
response.replies[0].createShape.objectId);
}
จัดรูปแบบข้อความรูปร่าง
function formatShapeText(presentationId, shapeId) {
var requests = [{
"updateTextStyle": {
"objectId": shapeId,
"fields": "foregroundColor,bold,italic,fontFamily,fontSize,underline",
"style": {
"foregroundColor": {
"opaqueColor": {
"themeColor": "ACCENT5"
}
},
"bold": true,
"italic": true,
"underline": true,
"fontFamily": "Corsiva",
"fontSize": {
"magnitude": 18,
"unit": "PT"
}
},
"textRange": {
"type": "ALL"
}
}
}];
var response =
Slides.Presentations.batchUpdate({'requests': requests}, presentationId);
}
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2024-08-21 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2024-08-21 UTC"],[[["The provided Google Apps Script code snippets demonstrate how to programmatically create and manipulate Google Slides presentations."],["The code covers functionalities such as creating presentations and slides, reading element IDs, adding text boxes, and formatting text within those boxes."],["Users can leverage these functions to automate presentation creation, customization, and content population, reducing manual effort and improving efficiency."],["Each function is independent and focuses on a specific task, allowing for flexibility in combining and using them to suit different use cases."],["Developers can adapt these examples to build more complex scripts for diverse slide manipulation scenarios within their applications or workflows."]]],[]]