Class PictureFill
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
PictureFill
Một lớp phủ hiển thị hình ảnh được kéo giãn theo kích thước của vùng chứa.
Phương thức
Phương thức | Loại dữ liệu trả về | Mô tả ngắn |
getAs(contentType) | Blob | Trả về dữ liệu bên trong đối tượng này dưới dạng một blob được chuyển đổi thành loại nội dung đã chỉ định. |
getBlob() | Blob | Trả về dữ liệu bên trong đối tượng này dưới dạng blob. |
getContentUrl() | String | Lấy URL của hình ảnh. |
getSourceUrl() | String | Lấy URL nguồn của hình ảnh (nếu có). |
Tài liệu chi tiết
getAs(contentType)
Trả về dữ liệu bên trong đối tượng này dưới dạng một blob được chuyển đổi thành loại nội dung đã chỉ định. Phương thức này thêm đuôi tệp thích hợp vào tên tệp, ví dụ: "myfile.pdf". Tuy nhiên, hàm này giả định rằng phần tên tệp theo sau dấu chấm cuối cùng (nếu có) là một đuôi tệp hiện có cần được thay thế. Do đó, "ShoppingList.12.25.2014" sẽ trở thành "ShoppingList.12.25.pdf".
Để xem hạn mức hằng ngày cho lượt chuyển đổi, hãy xem bài viết Hạn mức cho Dịch vụ của Google. Các miền Google Workspace mới tạo có thể tạm thời phải tuân theo hạn mức nghiêm ngặt hơn.
Tham số
Tên | Loại | Mô tả |
contentType | String | Loại MIME cần chuyển đổi sang. Đối với hầu hết các blob, 'application/pdf' là tuỳ chọn hợp lệ duy nhất. Đối với hình ảnh ở định dạng BMP, GIF, JPEG hoặc PNG, bất kỳ 'image/bmp' , 'image/gif' , 'image/jpeg' hoặc 'image/png' nào cũng đều hợp lệ. Đối với tài liệu Google Tài liệu, 'text/markdown' cũng hợp lệ. |
Cầu thủ trả bóng
Blob
– Dữ liệu dưới dạng blob.
getBlob()
Trả về dữ liệu bên trong đối tượng này dưới dạng blob.
Cầu thủ trả bóng
Blob
– Dữ liệu dưới dạng blob.
getContentUrl()
Lấy URL của hình ảnh.
URL này được gắn thẻ với tài khoản của người yêu cầu, vì vậy, bất kỳ ai có URL này đều có thể truy cập vào hình ảnh dưới vai trò là người yêu cầu ban đầu. Bạn có thể mất quyền truy cập vào hình ảnh nếu chế độ cài đặt chia sẻ của bản trình bày thay đổi. URL sẽ hết hạn sau một khoảng thời gian ngắn.
Cầu thủ trả bóng
String
Ủy quyền
Các tập lệnh sử dụng phương thức này yêu cầu được uỷ quyền với một hoặc nhiều phạm vi sau:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getSourceUrl()
Lấy URL nguồn của hình ảnh (nếu có).
Khi một hình ảnh được chèn theo URL, hàm này sẽ trả về URL được cung cấp trong quá trình chèn hình ảnh.
Cầu thủ trả bóng
String
– URL hình ảnh hoặc null
nếu hình ảnh không có URL nguồn
Ủy quyền
Các tập lệnh sử dụng phương thức này yêu cầu được uỷ quyền với một hoặc nhiều phạm vi sau:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[[["\u003cp\u003ePictureFill is a tool that stretches an image to fit the dimensions of its container.\u003c/p\u003e\n"],["\u003cp\u003eIt provides methods like \u003ccode\u003egetAs\u003c/code\u003e, \u003ccode\u003egetBlob\u003c/code\u003e, \u003ccode\u003egetContentUrl\u003c/code\u003e, and \u003ccode\u003egetSourceUrl\u003c/code\u003e to manipulate the image data and URLs.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egetContentUrl\u003c/code\u003e and \u003ccode\u003egetSourceUrl\u003c/code\u003e methods require specific authorization scopes for use.\u003c/p\u003e\n"],["\u003cp\u003eWhile \u003ccode\u003egetContentUrl\u003c/code\u003e provides a temporary, access-controlled image URL, \u003ccode\u003egetSourceUrl\u003c/code\u003e retrieves the original URL if the image was inserted via URL.\u003c/p\u003e\n"]]],["PictureFill renders an image stretched to its container's dimensions. Key actions include: `getAs(contentType)` returning blob data converted to a specified type, with filename adjustments; `getBlob()` returning data as a blob; `getContentUrl()` retrieving a URL to the image, expiring after a short time and tied to the requester's account. Lastly, `getSourceUrl()` fetches the original image's source URL, if available, otherwise returning null. These method are accessible if authorized by the correct scopes.\n"],null,["# Class PictureFill\n\nPictureFill\n\nA fill that renders an image that's stretched to the dimensions of its container. \n\n### Methods\n\n| Method | Return type | Brief description |\n|--------------------------------------|---------------------------|---------------------------------------------------------------------------------------|\n| [getAs(contentType)](#getAs(String)) | [Blob](../base/blob.html) | Return the data inside this object as a blob converted to the specified content type. |\n| [getBlob()](#getBlob()) | [Blob](../base/blob.html) | Return the data inside this object as a blob. |\n| [getContentUrl()](#getContentUrl()) | `String` | Gets a URL to the image. |\n| [getSourceUrl()](#getSourceUrl()) | `String` | Gets the image's source URL, if available. |\n\nDetailed documentation\n----------------------\n\n### `get``As(contentType)`\n\nReturn the data inside this object as a blob converted to the specified content type. This\nmethod adds the appropriate extension to the filename---for example, \"myfile.pdf\". However, it\nassumes that the part of the filename that follows the last period (if any) is an existing\nextension that should be replaced. Consequently, \"ShoppingList.12.25.2014\" becomes\n\"ShoppingList.12.25.pdf\".\n\nTo view the daily quotas for conversions, see [Quotas for Google\nServices](https://developers.google.com/apps-script/guides/services/quotas). Newly created Google Workspace domains might be temporarily subject to stricter\nquotas.\n\n#### Parameters\n\n| Name | Type | Description |\n|-----------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `content``Type` | `String` | The MIME type to convert to. For most blobs, `'application/pdf'` is the only valid option. For images in BMP, GIF, JPEG, or PNG format, any of `'image/bmp'`, `'image/gif'`, `'image/jpeg'`, or `'image/png'` are also valid. For a Google Docs document, `'text/markdown'` is also valid. |\n\n#### Return\n\n\n[Blob](../base/blob.html) --- The data as a blob.\n\n*** ** * ** ***\n\n### `get``Blob()`\n\nReturn the data inside this object as a blob.\n\n#### Return\n\n\n[Blob](../base/blob.html) --- The data as a blob.\n\n*** ** * ** ***\n\n### `get``Content``Url()`\n\nGets a URL to the image.\n\nThis URL is tagged with the account of the requester, so anyone with the URL effectively\naccesses the image as the original requester. Access to the image may be lost if the\npresentation's sharing settings change. The URL expires after a short period of time.\n\n#### Return\n\n\n`String`\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/presentations.currentonly`\n- `https://www.googleapis.com/auth/presentations`\n\n*** ** * ** ***\n\n### `get``Source``Url()`\n\nGets the image's source URL, if available.\n\nWhen an image is inserted by URL, returns the URL provided during image insertion.\n\n#### Return\n\n\n`String` --- the image URL or `null` if the image does not have a source URL\n\n#### Authorization\n\nScripts that use this method require authorization with one or more of the following [scopes](/apps-script/concepts/scopes#setting_explicit_scopes):\n\n- `https://www.googleapis.com/auth/presentations.currentonly`\n- `https://www.googleapis.com/auth/presentations`"]]