如何高效将100张图片分别插入Google Docs的100个独立页面?
Got it, inserting 100 images one per page manually is such a time-suck—let’s cover two efficient solutions to get this done fast, whether you prefer code or no-code approaches!
方法1:Google Apps Script自动化(最高效,推荐)
This method lets you automate the entire process with a simple script, perfect for large batches like 100 images.
步骤:
- Prepare your images: Upload all 100 images to a single Google Drive folder. For easier sorting, name them sequentially (e.g.,
img_001.jpg,img_002.jpg...). Grab the folder ID from the Drive URL (it’s the long string afterfolders/in the address bar). - Open the script editor: In your Google Docs document, go to
Extensions > Apps Scriptto launch the editor. - Replace the default code: Paste the script below, then update the
FOLDER_ID,PAGE_WIDTH, andPAGE_HEIGHTvalues to match your needs (default is A4 size). - Run the script: Save the project (name it something like "Image Per Page Importer"), click the run button ▶️, and grant the necessary permissions (Google will warn you it’s an unverified app—this is safe since you wrote it yourself; just follow the "Advanced" link to proceed).
function insertImagesPerPage() { // 配置参数 const FOLDER_ID = "YOUR_DRIVE_FOLDER_ID_HERE"; // 替换成你的图片文件夹ID const PAGE_WIDTH = 595; // A4宽度(像素),可根据你的文档调整 const PAGE_HEIGHT = 842; // A4高度(像素) const MARGIN = 40; // 边距,避免图片贴边 const doc = DocumentApp.getActiveDocument(); const body = doc.getBody(); const folder = DriveApp.getFolderById(FOLDER_ID); const files = folder.getFilesByType(MimeType.JPEG) // 可根据图片类型修改,比如PNG .sort((a, b) => a.getName().localeCompare(b.getName())); // 按文件名排序 // 清空现有内容(可选,根据你的需求调整) body.clear(); while (files.hasNext()) { const file = files.next(); const imageBlob = file.getBlob(); // 插入图片并调整大小适配页面 const image = body.appendImage(imageBlob); image.setWidth(PAGE_WIDTH - 2 * MARGIN); image.setHeight((PAGE_WIDTH - 2 * MARGIN) * image.getHeight() / image.getWidth()); // 保持宽高比 // 在图片后插入分页符(最后一张图片不需要) if (files.hasNext()) { body.appendPageBreak(); } } }
自定义提示:
- If your images are PNGs, change
MimeType.JPEGtoMimeType.PNGin the script. - If you don’t want to clear existing content, remove the
body.clear();line. - To sort images by upload date instead of filename, replace the sort line with
.sort((a, b) => b.getDateCreated() - a.getDateCreated()).
方法2:无代码批量导入+快速分页
If you’re not comfortable with scripts, this manual-but-fast method works too:
步骤:
- Organize local images: Put all 100 images in a single folder on your computer, named sequentially (e.g.,
img1toimg100) so they import in order. - Batch import images: Open your Google Docs, delete any existing content (if needed), then go to
Insert > Images > Upload from computer. Select all 100 images at once—they’ll all insert into the document in a single continuous block. - Resize images (if needed): Select all images (drag to highlight or press
Ctrl+A), right-click one, chooseSize and position, and set the width to match your page width minus margins (e.g., 6.5 inches for A4 with 0.5-inch margins). - Quickly add page breaks: Place your cursor right after the first image, press
Ctrl+Enter(Windows) orCmd+Enter(Mac) to insert a page break. Then pressCtrl+Y(Windows) orCmd+Y(Mac) repeatedly—this repeats the last action (inserting a page break) and will automatically jump to the end of the next image each time. Do this 99 times and you’ll have each image on its own page!
Pro tip:
If you find pressing Ctrl+Y 99 times tedious, you can use a keyboard macro tool (like AutoHotkey on Windows or Keyboard Maestro on Mac) to automate the repeat action.
内容的提问来源于stack exchange,提问作者Yash Pathak
相关产品推荐
相关产品推荐

