google-slides
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseGoogle Slides
Google Slides
Interact with Google Slides for presentation creation, slide management, and content insertion.
通过本工具可与Google Slides交互,实现演示文稿创建、幻灯片管理及内容插入操作。
Installation
安装
-
Install Python dependencies:bash
pip install --user google-auth google-auth-oauthlib google-api-python-client keyring pyyaml -
Download the skill from Releases or use directly from this repository.
-
安装Python依赖包:bash
pip install --user google-auth google-auth-oauthlib google-api-python-client keyring pyyaml -
下载技能包:从Releases下载,或直接使用本仓库中的内容。
Setup Verification
安装验证
After installation, verify the skill is properly configured:
bash
python scripts/google-slides.py checkThis will check:
- Python dependencies (google-auth, google-auth-oauthlib, google-api-python-client, keyring, pyyaml)
- Authentication configuration
- Connectivity to Google Slides API
If anything is missing, the check command will provide setup instructions.
安装完成后,验证技能包是否配置正确:
bash
python scripts/google-slides.py check该命令会检查以下内容:
- Python依赖包(google-auth、google-auth-oauthlib、google-api-python-client、keyring、pyyaml)
- 身份验证配置
- 与Google Slides API的连接性
若有缺失项,检查命令会提供对应的设置说明。
Authentication
身份验证
Google Slides uses OAuth 2.0 for authentication. For complete setup instructions, see:
- GCP Project Setup Guide - Create project, enable Slides API
- Google OAuth Setup Guide - Configure credentials
Google Slides采用OAuth 2.0进行身份验证。完整设置说明请参考:
- GCP项目设置指南 - 创建项目、启用Slides API
- Google OAuth设置指南 - 配置凭证
Quick Start
快速开始
-
Create:
~/.config/agent-skills/google.yamlyamloauth_client: client_id: your-client-id.apps.googleusercontent.com client_secret: your-client-secret -
Runto trigger OAuth flow and verify setup.
python scripts/google-slides.py check
-
创建文件:
~/.config/agent-skills/google.yamlyamloauth_client: client_id: your-client-id.apps.googleusercontent.com client_secret: your-client-secret -
运行触发OAuth流程并验证设置。
python scripts/google-slides.py check
OAuth Scopes
OAuth权限范围
The skill requests granular scopes for different operations:
| Scope | Permission | Used For |
|---|---|---|
| Read presentations | Reading presentation metadata and content |
| Full access | Creating and modifying presentations |
| Read Drive files | Exporting presentations as PDF |
本技能包针对不同操作请求精细化的权限范围:
| 权限范围 | 权限说明 | 适用场景 |
|---|---|---|
| 读取演示文稿 | 读取演示文稿元数据和内容 |
| 完全访问权限 | 创建和修改演示文稿 |
| 读取云端硬盘文件 | 将演示文稿导出为PDF格式 |
Scope Errors
权限范围错误
If you encounter "insufficient scope" errors, revoke your token and re-authenticate:
- Revoke at https://myaccount.google.com/permissions
- Clear token:
keyring del agent-skills google-slides-token-json - Re-run:
python scripts/google-slides.py check
若遇到“权限不足”错误,请撤销现有令牌并重新进行身份验证:
- 访问https://myaccount.google.com/permissions撤销权限
- 清除令牌:
keyring del agent-skills google-slides-token-json - 重新运行:
python scripts/google-slides.py check
Commands
命令说明
check
check
Verify configuration and connectivity.
bash
python scripts/google-slides.py checkThis validates:
- Python dependencies are installed
- Authentication is configured
- Can connect to Google Slides API
- Creates a test presentation to verify write access
验证配置和连接性。
bash
python scripts/google-slides.py check该命令会验证:
- Python依赖包已安装
- 身份验证已配置
- 可连接到Google Slides API
- 创建测试演示文稿以验证写入权限
auth setup
auth setup
Store OAuth 2.0 client credentials for custom OAuth flow.
bash
python scripts/google-slides.py auth setup \
--client-id YOUR_CLIENT_ID \
--client-secret YOUR_CLIENT_SECRETCredentials are saved to .
~/.config/agent-skills/google-slides.yamlOptions:
- - OAuth 2.0 client ID (required)
--client-id - - OAuth 2.0 client secret (required)
--client-secret
存储OAuth 2.0客户端凭证,用于自定义OAuth流程。
bash
python scripts/google-slides.py auth setup \
--client-id YOUR_CLIENT_ID \
--client-secret YOUR_CLIENT_SECRET凭证将保存到文件中。
~/.config/agent-skills/google-slides.yaml选项:
- - OAuth 2.0客户端ID(必填)
--client-id - - OAuth 2.0客户端密钥(必填)
--client-secret
presentations create
presentations create
Create a new Google Slides presentation.
bash
python scripts/google-slides.py presentations create --title "My Presentation"Options:
- - Presentation title (required)
--title - - Output as JSON
--json
Example:
bash
python scripts/google-slides.py presentations create --title "Q4 Review"创建新的Google Slides演示文稿。
bash
python scripts/google-slides.py presentations create --title "My Presentation"选项:
- - 演示文稿标题(必填)
--title - - 以JSON格式输出结果
--json
示例:
bash
python scripts/google-slides.py presentations create --title "Q4 Review"Output:
输出:
✓ Presentation created successfully
✓ 演示文稿创建成功
Title: Q4 Review
标题: Q4 Review
Presentation ID: 1abc...xyz
演示文稿ID: 1abc...xyz
Slides: 1
幻灯片数量: 1
undefinedundefinedpresentations get
presentations get
Get presentation metadata and structure.
bash
python scripts/google-slides.py presentations get PRESENTATION_IDArguments:
- - The Google Slides presentation ID
presentation_id
Options:
- - Output full presentation structure as JSON
--json
Example:
bash
python scripts/google-slides.py presentations get 1abc...xyz获取演示文稿的元数据和结构。
bash
python scripts/google-slides.py presentations get PRESENTATION_ID参数:
- - Google Slides演示文稿ID
presentation_id
选项:
- - 以JSON格式输出完整的演示文稿结构
--json
示例:
bash
python scripts/google-slides.py presentations get 1abc...xyzOutput:
输出:
Title: Q4 Review
标题: Q4 Review
Presentation ID: 1abc...xyz
演示文稿ID: 1abc...xyz
Slides: 5
幻灯片数量: 5
Slides:
幻灯片列表:
Slide 1:
幻灯片1:
ID: slide_id_1
ID: slide_id_1
Layout: TITLE
布局: TITLE
Elements: 2 (2 text, 0 shapes, 0 images, 0 other)
元素: 2个(2个文本、0个形状、0个图片、0个其他元素)
Slide 2:
幻灯片2:
ID: slide_id_2
ID: slide_id_2
Layout: TITLE_AND_BODY
布局: TITLE_AND_BODY
Elements: 3 (2 text, 1 shapes, 0 images, 0 other)
元素: 3个(2个文本、1个形状、0个图片、0个其他元素)
undefinedundefinedpresentations read
presentations read
Read presentation text content from all slides, or export as PDF.
bash
python scripts/google-slides.py presentations read PRESENTATION_IDArguments:
- - The Google Slides presentation ID
presentation_id
Options:
- - Output format:
--format(default) ortextpdf - ,
--output- Output file path (used with pdf format)-o - - Output as JSON with content field (for text format)
--json
Example:
bash
undefined读取所有幻灯片的文本内容,或导出为PDF格式。
bash
python scripts/google-slides.py presentations read PRESENTATION_ID参数:
- - Google Slides演示文稿ID
presentation_id
选项:
- - 输出格式:
--format(默认)或textpdf - ,
--output- 输出文件路径(仅在pdf格式下使用)-o - - 以JSON格式输出内容字段(仅在text格式下使用)
--json
示例:
bash
undefinedRead as text (default)
以文本格式读取(默认)
python scripts/google-slides.py presentations read 1abc...xyz
python scripts/google-slides.py presentations read 1abc...xyz
Export as PDF
导出为PDF格式
python scripts/google-slides.py presentations read 1abc...xyz --format pdf --output presentation.pdf
python scripts/google-slides.py presentations read 1abc...xyz --format pdf --output presentation.pdf
Output (text format):
输出(文本格式):
--- Slide 1 ---
--- 幻灯片1 ---
Welcome to Our Product
欢迎了解我们的产品
An introduction to key features
核心功能介绍
--- Slide 2 ---
--- 幻灯片2 ---
Key Metrics
关键指标
Revenue: $1.2M
营收: $1.2M
Users: 50,000
用户数: 50,000
--- Slide 3 ---
--- 幻灯片3 ---
| Quarter | Revenue | Growth |
| 季度 | 营收 | 增长率 |
| --- | --- | --- |
| --- | --- | --- |
| Q1 | $250K | 10% |
| Q1 | $250K | 10% |
| Q2 | $300K | 20% |
| Q2 | $300K | 20% |
**Note:** Text format extracts text from all shapes, text boxes, and tables on each slide (tables formatted as markdown). PDF export uses Google's native Drive API export, which requires the `drive.readonly` scope.
**注意:** 文本格式会提取每张幻灯片上所有形状、文本框和表格中的文本(表格会转换为Markdown格式)。PDF导出使用Google原生云端硬盘API,需要`drive.readonly`权限范围。slides create
slides create
Add a new slide to a presentation.
bash
python scripts/google-slides.py slides create PRESENTATION_ID --layout BLANKArguments:
- - The Google Slides presentation ID
presentation_id
Options:
- - Slide layout (default: BLANK)
--layout- - Empty slide
BLANK - - Title slide
TITLE - - Title and body text
TITLE_AND_BODY - - Title only
TITLE_ONLY - - Section header
SECTION_HEADER - - Section with description
SECTION_TITLE_AND_DESCRIPTION - - Single column of text
ONE_COLUMN_TEXT - - Large centered text
MAIN_POINT - - Large number display
BIG_NUMBER
- - Insert at specific position (0-based, optional)
--index - - Output API response as JSON
--json
Example:
bash
undefined向演示文稿中添加新幻灯片。
bash
python scripts/google-slides.py slides create PRESENTATION_ID --layout BLANK参数:
- - Google Slides演示文稿ID
presentation_id
选项:
- - 幻灯片布局(默认: BLANK)
--layout- - 空白幻灯片
BLANK - - 标题幻灯片
TITLE - - 标题与正文
TITLE_AND_BODY - - 仅标题
TITLE_ONLY - - 章节标题
SECTION_HEADER - - 章节标题与描述
SECTION_TITLE_AND_DESCRIPTION - - 单列文本
ONE_COLUMN_TEXT - - 居中大文本
MAIN_POINT - - 大数字展示
BIG_NUMBER
- - 插入到指定位置(从0开始计数,可选)
--index - - 以JSON格式输出API响应
--json
示例:
bash
undefinedAdd blank slide at the end
在末尾添加空白幻灯片
python scripts/google-slides.py slides create 1abc...xyz --layout BLANK
python scripts/google-slides.py slides create 1abc...xyz --layout BLANK
Add title slide at position 0
在位置0添加标题幻灯片
python scripts/google-slides.py slides create 1abc...xyz --layout TITLE --index 0
python scripts/google-slides.py slides create 1abc...xyz --layout TITLE --index 0
Output:
输出:
✓ Slide created successfully
✓ 幻灯片创建成功
Slide ID: slide_abc123
幻灯片ID: slide_abc123
Layout: TITLE
布局: TITLE
See [references/layouts-guide.md](references/layouts-guide.md) for layout details.
布局详情请参考[references/layouts-guide.md](references/layouts-guide.md)。slides delete
slides delete
Delete a slide from a presentation.
bash
python scripts/google-slides.py slides delete PRESENTATION_ID --slide-id SLIDE_IDArguments:
- - The Google Slides presentation ID
presentation_id
Options:
- - Slide object ID to delete (required, not the index!)
--slide-id - - Output API response as JSON
--json
Example:
bash
undefined从演示文稿中删除幻灯片。
bash
python scripts/google-slides.py slides delete PRESENTATION_ID --slide-id SLIDE_ID参数:
- - Google Slides演示文稿ID
presentation_id
选项:
- - 要删除的幻灯片对象ID(必填,不是索引!)
--slide-id - - 以JSON格式输出API响应
--json
示例:
bash
undefinedGet slide IDs first
先获取幻灯片ID
python scripts/google-slides.py presentations get 1abc...xyz --json | jq '.slides[].objectId'
python scripts/google-slides.py presentations get 1abc...xyz --json | jq '.slides[].objectId'
Delete a slide
删除幻灯片
python scripts/google-slides.py slides delete 1abc...xyz --slide-id slide_abc123
python scripts/google-slides.py slides delete 1abc...xyz --slide-id slide_abc123
Output:
输出:
✓ Slide deleted successfully
✓ 幻灯片删除成功
**Warning:** Cannot delete the last remaining slide in a presentation.
**警告:** 无法删除演示文稿中最后一张剩余的幻灯片。text insert
text insert
Insert text into a slide.
bash
python scripts/google-slides.py text insert PRESENTATION_ID \
--slide-id SLIDE_ID \
--text "Hello World"Arguments:
- - The Google Slides presentation ID
presentation_id
Options:
- - Slide object ID (required)
--slide-id - - Text to insert (required)
--text - - X position in points (default: 100)
--x - - Y position in points (default: 100)
--y - - Text box width in points (default: 400)
--width - - Text box height in points (default: 100)
--height - - Output API response as JSON
--json
Example:
bash
undefined在幻灯片中插入文本。
bash
python scripts/google-slides.py text insert PRESENTATION_ID \
--slide-id SLIDE_ID \
--text "Hello World"参数:
- - Google Slides演示文稿ID
presentation_id
选项:
- - 幻灯片对象ID(必填)
--slide-id - - 要插入的文本(必填)
--text - - X轴位置(单位:磅,默认: 100)
--x - - Y轴位置(单位:磅,默认: 100)
--y - - 文本框宽度(单位:磅,默认: 400)
--width - - 文本框高度(单位:磅,默认: 100)
--height - - 以JSON格式输出API响应
--json
示例:
bash
undefinedInsert text at default position
在默认位置插入文本
python scripts/google-slides.py text insert 1abc...xyz
--slide-id slide_abc123
--text "Hello World"
--slide-id slide_abc123
--text "Hello World"
python scripts/google-slides.py text insert 1abc...xyz
--slide-id slide_abc123
--text "Hello World"
--slide-id slide_abc123
--text "Hello World"
Insert text at custom position
在自定义位置插入文本
python scripts/google-slides.py text insert 1abc...xyz
--slide-id slide_abc123
--text "Q4 Results"
--x 50 --y 50 --width 500 --height 80
--slide-id slide_abc123
--text "Q4 Results"
--x 50 --y 50 --width 500 --height 80
python scripts/google-slides.py text insert 1abc...xyz
--slide-id slide_abc123
--text "Q4 Results"
--x 50 --y 50 --width 500 --height 80
--slide-id slide_abc123
--text "Q4 Results"
--x 50 --y 50 --width 500 --height 80
Output:
输出:
✓ Text inserted successfully
✓ 文本插入成功
Text: Q4 Results
文本内容: Q4 Results
Position: (50.0, 50.0) points
位置: (50.0, 50.0) 磅
Size: 500.0 x 80.0 points
尺寸: 500.0 x 80.0 磅
**Note:** Coordinates are in points (1 point = 1/72 inch). Origin (0,0) is top-left.
**注意:** 坐标单位为磅(1磅 = 1/72英寸)。原点(0,0)位于幻灯片左上角。shapes create
shapes create
Create a shape on a slide.
bash
python scripts/google-slides.py shapes create PRESENTATION_ID \
--slide-id SLIDE_ID \
--shape-type RECTANGLEArguments:
- - The Google Slides presentation ID
presentation_id
Options:
- - Slide object ID (required)
--slide-id - - Shape type (required)
--shape-type- ,
RECTANGLE,ELLIPSE,TRIANGLE,PENTAGONHEXAGON - ,
STAR_5,STAR_8,STAR_24STAR_32 - ,
CLOUD,HEART,LIGHTNING_BOLT,MOONSUN - ,
ARROW_NORTH,ARROW_EAST,ARROW_SOUTHARROW_WEST - And many more (see references/shapes-guide.md)
- - X position in points (default: 100)
--x - - Y position in points (default: 100)
--y - - Shape width in points (default: 200)
--width - - Shape height in points (default: 200)
--height - - Output API response as JSON
--json
Example:
bash
undefined在幻灯片中创建形状。
bash
python scripts/google-slides.py shapes create PRESENTATION_ID \
--slide-id SLIDE_ID \
--shape-type RECTANGLE参数:
- - Google Slides演示文稿ID
presentation_id
选项:
- - 幻灯片对象ID(必填)
--slide-id - - 形状类型(必填)
--shape-type- ,
RECTANGLE,ELLIPSE,TRIANGLE,PENTAGONHEXAGON - ,
STAR_5,STAR_8,STAR_24STAR_32 - ,
CLOUD,HEART,LIGHTNING_BOLT,MOONSUN - ,
ARROW_NORTH,ARROW_EAST,ARROW_SOUTHARROW_WEST - 更多形状类型请参考references/shapes-guide.md
- - X轴位置(单位:磅,默认: 100)
--x - - Y轴位置(单位:磅,默认: 100)
--y - - 形状宽度(单位:磅,默认: 200)
--width - - 形状高度(单位:磅,默认: 200)
--height - - 以JSON格式输出API响应
--json
示例:
bash
undefinedCreate rectangle
创建矩形
python scripts/google-slides.py shapes create 1abc...xyz
--slide-id slide_abc123
--shape-type RECTANGLE
--slide-id slide_abc123
--shape-type RECTANGLE
python scripts/google-slides.py shapes create 1abc...xyz
--slide-id slide_abc123
--shape-type RECTANGLE
--slide-id slide_abc123
--shape-type RECTANGLE
Create star with custom size
创建自定义尺寸的星形
python scripts/google-slides.py shapes create 1abc...xyz
--slide-id slide_abc123
--shape-type STAR_5
--x 300 --y 200 --width 150 --height 150
--slide-id slide_abc123
--shape-type STAR_5
--x 300 --y 200 --width 150 --height 150
python scripts/google-slides.py shapes create 1abc...xyz
--slide-id slide_abc123
--shape-type STAR_5
--x 300 --y 200 --width 150 --height 150
--slide-id slide_abc123
--shape-type STAR_5
--x 300 --y 200 --width 150 --height 150
Output:
输出:
✓ Shape created successfully
✓ 形状创建成功
Type: STAR_5
类型: STAR_5
Position: (300.0, 200.0) points
位置: (300.0, 200.0) 磅
Size: 150.0 x 150.0 points
尺寸: 150.0 x 150.0 磅
See [references/shapes-guide.md](references/shapes-guide.md) for all shape types.
所有形状类型请参考[references/shapes-guide.md](references/shapes-guide.md)。images create
images create
Insert an image into a slide.
bash
python scripts/google-slides.py images create PRESENTATION_ID \
--slide-id SLIDE_ID \
--image-url "https://example.com/image.png"Arguments:
- - The Google Slides presentation ID
presentation_id
Options:
- - Slide object ID (required)
--slide-id - - Image URL (required, must be publicly accessible)
--image-url - - X position in points (default: 100)
--x - - Y position in points (default: 100)
--y - - Image width in points (default: 300)
--width - - Image height in points (default: 200)
--height - - Output API response as JSON
--json
Example:
bash
python scripts/google-slides.py images create 1abc...xyz \
--slide-id slide_abc123 \
--image-url "https://example.com/chart.png" \
--x 50 --y 150 --width 400 --height 300在幻灯片中插入图片。
bash
python scripts/google-slides.py images create PRESENTATION_ID \
--slide-id SLIDE_ID \
--image-url "https://example.com/image.png"参数:
- - Google Slides演示文稿ID
presentation_id
选项:
- - 幻灯片对象ID(必填)
--slide-id - - 图片URL(必填,必须可公开访问)
--image-url - - X轴位置(单位:磅,默认: 100)
--x - - Y轴位置(单位:磅,默认: 100)
--y - - 图片宽度(单位:磅,默认: 300)
--width - - 图片高度(单位:磅,默认: 200)
--height - - 以JSON格式输出API响应
--json
示例:
bash
python scripts/google-slides.py images create 1abc...xyz \
--slide-id slide_abc123 \
--image-url "https://example.com/chart.png" \
--x 50 --y 150 --width 400 --height 300Output:
输出:
✓ Image created successfully
✓ 图片插入成功
Position: (50.0, 150.0) points
位置: (50.0, 150.0) 磅
Size: 400.0 x 300.0 points
尺寸: 400.0 x 300.0 磅
**Note:** The image URL must be publicly accessible or authenticated with Google.
**注意:** 图片URL必须可公开访问,或已通过Google身份验证。Examples
使用示例
Create a simple presentation
创建简单演示文稿
bash
undefinedbash
undefinedCreate presentation
创建演示文稿
PRES_ID=$(python scripts/google-slides.py presentations create
--title "Team Update" --json | jq -r '.presentationId')
--title "Team Update" --json | jq -r '.presentationId')
PRES_ID=$(python scripts/google-slides.py presentations create
--title "Team Update" --json | jq -r '.presentationId')
--title "Team Update" --json | jq -r '.presentationId')
Get the default slide ID
获取默认幻灯片ID
SLIDE_ID=$(python scripts/google-slides.py presentations get $PRES_ID --json |
jq -r '.slides[0].objectId')
jq -r '.slides[0].objectId')
SLIDE_ID=$(python scripts/google-slides.py presentations get $PRES_ID --json |
jq -r '.slides[0].objectId')
jq -r '.slides[0].objectId')
Add title text
添加标题文本
python scripts/google-slides.py text insert $PRES_ID
--slide-id $SLIDE_ID
--text "Q4 Team Update"
--x 50 --y 50 --width 600 --height 100
--slide-id $SLIDE_ID
--text "Q4 Team Update"
--x 50 --y 50 --width 600 --height 100
python scripts/google-slides.py text insert $PRES_ID
--slide-id $SLIDE_ID
--text "Q4团队更新"
--x 50 --y 50 --width 600 --height 100
--slide-id $SLIDE_ID
--text "Q4团队更新"
--x 50 --y 50 --width 600 --height 100
Add subtitle
添加副标题
python scripts/google-slides.py text insert $PRES_ID
--slide-id $SLIDE_ID
--text "December 2024"
--x 50 --y 180 --width 600 --height 50
--slide-id $SLIDE_ID
--text "December 2024"
--x 50 --y 180 --width 600 --height 50
undefinedpython scripts/google-slides.py text insert $PRES_ID
--slide-id $SLIDE_ID
--text "2024年12月"
--x 50 --y 180 --width 600 --height 50
--slide-id $SLIDE_ID
--text "2024年12月"
--x 50 --y 180 --width 600 --height 50
undefinedBuild a multi-slide presentation
创建多幻灯片演示文稿
bash
#!/bin/bash
PRES_ID="your-presentation-id"bash
#!/bin/bash
PRES_ID="your-presentation-id"Add content slide
添加内容幻灯片
SLIDE_ID=$(python scripts/google-slides.py slides create $PRES_ID
--layout TITLE_AND_BODY --json | jq -r '.replies[0].createSlide.objectId')
--layout TITLE_AND_BODY --json | jq -r '.replies[0].createSlide.objectId')
SLIDE_ID=$(python scripts/google-slides.py slides create $PRES_ID
--layout TITLE_AND_BODY --json | jq -r '.replies[0].createSlide.objectId')
--layout TITLE_AND_BODY --json | jq -r '.replies[0].createSlide.objectId')
Add title
添加标题
python scripts/google-slides.py text insert $PRES_ID
--slide-id $SLIDE_ID
--text "Key Metrics"
--x 50 --y 30 --width 600 --height 60
--slide-id $SLIDE_ID
--text "Key Metrics"
--x 50 --y 30 --width 600 --height 60
python scripts/google-slides.py text insert $PRES_ID
--slide-id $SLIDE_ID
--text "关键指标"
--x 50 --y 30 --width 600 --height 60
--slide-id $SLIDE_ID
--text "关键指标"
--x 50 --y 30 --width 600 --height 60
Add chart image
添加图表图片
python scripts/google-slides.py images create $PRES_ID
--slide-id $SLIDE_ID
--image-url "https://example.com/metrics.png"
--x 100 --y 120 --width 500 --height 350
--slide-id $SLIDE_ID
--image-url "https://example.com/metrics.png"
--x 100 --y 120 --width 500 --height 350
python scripts/google-slides.py images create $PRES_ID
--slide-id $SLIDE_ID
--image-url "https://example.com/metrics.png"
--x 100 --y 120 --width 500 --height 350
--slide-id $SLIDE_ID
--image-url "https://example.com/metrics.png"
--x 100 --y 120 --width 500 --height 350
Add another slide with shapes
添加带形状的另一张幻灯片
SLIDE2_ID=$(python scripts/google-slides.py slides create $PRES_ID
--layout BLANK --json | jq -r '.replies[0].createSlide.objectId')
--layout BLANK --json | jq -r '.replies[0].createSlide.objectId')
SLIDE2_ID=$(python scripts/google-slides.py slides create $PRES_ID
--layout BLANK --json | jq -r '.replies[0].createSlide.objectId')
--layout BLANK --json | jq -r '.replies[0].createSlide.objectId')
Add decorative shape
添加装饰性星形
python scripts/google-slides.py shapes create $PRES_ID
--slide-id $SLIDE2_ID
--shape-type STAR_5
--x 550 --y 30 --width 80 --height 80
--slide-id $SLIDE2_ID
--shape-type STAR_5
--x 550 --y 30 --width 80 --height 80
undefinedpython scripts/google-slides.py shapes create $PRES_ID
--slide-id $SLIDE2_ID
--shape-type STAR_5
--x 550 --y 30 --width 80 --height 80
--slide-id $SLIDE2_ID
--shape-type STAR_5
--x 550 --y 30 --width 80 --height 80
undefinedCreate presentation from data
基于数据创建演示文稿
bash
#!/bin/bashbash
#!/bin/bashCreate presentation
创建演示文稿
PRES_ID=$(python scripts/google-slides.py presentations create
--title "Sales Report" --json | jq -r '.presentationId')
--title "Sales Report" --json | jq -r '.presentationId')
PRES_ID=$(python scripts/google-slides.py presentations create
--title "销售报告" --json | jq -r '.presentationId')
--title "销售报告" --json | jq -r '.presentationId')
Add slide for each region
为每个区域添加幻灯片
for region in "North" "South" "East" "West"; do
SLIDE_ID=$(python scripts/google-slides.py slides create $PRES_ID
--layout TITLE_AND_BODY --json | jq -r '.replies[0].createSlide.objectId')
--layout TITLE_AND_BODY --json | jq -r '.replies[0].createSlide.objectId')
python scripts/google-slides.py text insert $PRES_ID
--slide-id $SLIDE_ID
--text "$region Region Sales"
--x 50 --y 30 --width 600 --height 80 done
--slide-id $SLIDE_ID
--text "$region Region Sales"
--x 50 --y 30 --width 600 --height 80 done
undefinedfor region in "北部" "南部" "东部" "西部"; do
SLIDE_ID=$(python scripts/google-slides.py slides create $PRES_ID
--layout TITLE_AND_BODY --json | jq -r '.replies[0].createSlide.objectId')
--layout TITLE_AND_BODY --json | jq -r '.replies[0].createSlide.objectId')
python scripts/google-slides.py text insert $PRES_ID
--slide-id $SLIDE_ID
--text "$region区域销售情况"
--x 50 --y 30 --width 600 --height 80 done
--slide-id $SLIDE_ID
--text "$region区域销售情况"
--x 50 --y 30 --width 600 --height 80 done
undefinedCoordinate System
坐标系统
Google Slides uses points for positioning and sizing:
- 1 point = 1/72 inch
- 1 inch = 72 points
- Origin (0, 0) is at the top-left corner
- Standard slide size: 720 x 540 points (10 x 7.5 inches)
Common reference positions:
(0, 0) (720, 0)
┌───────────────────────────────────────┐
│ Title area │
│ (50, 50, 620, 80) │
│ │
│ Content area │
│ (50, 150, 620, 350) │
│ │
│ │
└───────────────────────────────────────┘
(0, 540) (720, 540)Google Slides使用磅作为位置和尺寸的单位:
- 1磅 = 1/72英寸
- 1英寸 = 72磅
- 原点(0, 0)位于幻灯片左上角
- 标准幻灯片尺寸:720 x 540磅(10 x 7.5英寸)
常用参考位置:
(0, 0) (720, 0)
┌───────────────────────────────────────┐
│ 标题区域 │
│ (50, 50, 620, 80) │
│ │
│ 内容区域 │
│ (50, 150, 620, 350) │
│ │
│ │
└───────────────────────────────────────┘
(0, 540) (720, 540)Troubleshooting
故障排除
"Insufficient scope" errors
“权限不足”错误
You need to revoke and re-authenticate to grant additional permissions:
- Go to https://myaccount.google.com/permissions
- Find "Agent Skills" and remove access
- Delete stored token:
keyring del agent-skills google-slides-token-json - Run to re-authenticate
python scripts/google-slides.py check
需要撤销现有权限并重新验证以获取额外权限:
- 访问https://myaccount.google.com/permissions
- 找到“Agent Skills”并移除访问权限
- 删除存储的令牌:
keyring del agent-skills google-slides-token-json - 运行重新进行身份验证
python scripts/google-slides.py check
Cannot find presentation
无法找到演示文稿
Make sure you're using the correct presentation ID from the URL:
- URL:
https://docs.google.com/presentation/d/1abc...xyz/edit - Presentation ID:
1abc...xyz
确保使用的是URL中的正确演示文稿ID:
- URL:
https://docs.google.com/presentation/d/1abc...xyz/edit - 演示文稿ID:
1abc...xyz
Cannot find slide ID
无法找到幻灯片ID
Slide IDs are object IDs, not indices. Get them with:
bash
python scripts/google-slides.py presentations get $PRES_ID --json | \
jq -r '.slides[] | "\(.objectId) (index \(.slideProperties.slideIndex))"'幻灯片ID是对象ID,不是索引。可通过以下命令获取:
bash
python scripts/google-slides.py presentations get $PRES_ID --json | \
jq -r '.slides[] | "\(.objectId) (索引 \(.slideProperties.slideIndex))"'Image not appearing
图片无法显示
The image URL must be:
- Publicly accessible (no authentication required), OR
- Accessible to the Google account you're using
Test the URL in a browser. If it requires authentication, you'll need to:
- Upload the image to Google Drive
- Make it publicly accessible or share it with your Google account
- Use the Google Drive URL
图片URL必须满足以下条件之一:
- 可公开访问(无需身份验证),或
- 可被当前使用的Google账户访问
可在浏览器中测试URL。若需要身份验证,请执行以下步骤:
- 将图片上传到Google云端硬盘
- 设置为公开访问或与当前Google账户共享
- 使用Google云端硬盘URL
Slide position/size issues
幻灯片位置/尺寸问题
Remember:
- Coordinates are in points, not pixels
- Standard slide: 720 x 540 points
- Elements outside slide boundaries won't be visible
- Use ,
--x,--y,--widthto position elements--height
请记住:
- 坐标单位为磅,而非像素
- 标准幻灯片尺寸为720 x 540磅
- 超出幻灯片边界的元素将不可见
- 使用,
--x,--y,--width参数调整元素位置和尺寸--height
Dependencies not found
依赖包未找到
Install required dependencies:
bash
pip install --user google-auth google-auth-oauthlib google-api-python-client keyring pyyaml安装所需依赖包:
bash
pip install --user google-auth google-auth-oauthlib google-api-python-client keyring pyyamlOAuth flow fails
OAuth流程失败
Ensure your GCP project has:
- Google Slides API enabled ()
slides.googleapis.com - OAuth 2.0 credentials created
- OAuth consent screen configured
- Your email added as a test user (if app is in testing mode)
See docs/gcp-project-setup.md for detailed instructions.
确保你的GCP项目已完成以下设置:
- 已启用Google Slides API ()
slides.googleapis.com - 已创建OAuth 2.0凭证
- 已配置OAuth同意屏幕
- 若应用处于测试模式,已将你的邮箱添加为测试用户
详细说明请参考docs/gcp-project-setup.md。
Related Skills
相关技能
- Google Drive - File management (Drive manages file metadata, Slides manages content)
- Google Docs - Document creation and editing
- Google Sheets - Spreadsheet management
- Google Drive - 文件管理(云端硬盘管理文件元数据,Slides管理内容)
- Google Docs - 文档创建与编辑
- Google Sheets - 电子表格管理
API Reference
API参考
For advanced usage, see:
- Google Slides API Documentation
- Working with presentations
- Layouts guide
- Shapes guide
如需高级用法,请参考:
- Google Slides API文档
- 演示文稿操作指南
- 布局指南
- 形状指南