Class Bookmark
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Agregar a favoritos
Un objeto que representa un favorito.
const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
// Insert a bookmark at the cursor position (in the active tab) and log its ID.
const cursor = doc.getCursor();
const bookmark = documentTab.addBookmark(cursor);
Logger.log(bookmark.getId());
Documentación detallada
getId()
Obtiene el ID del Bookmark
. El ID es único dentro de DocumentTab
.
Volver
String
: Es el ID de Bookmark
, que es único dentro de DocumentTab
.
Autorización
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
getPosition()
Obtiene el Position
de Bookmark
dentro de DocumentTab
. El Position
sigue siendo preciso, siempre y cuando no se borre el Bookmark
, incluso si la secuencia de comandos cambia la estructura del documento.
Volver
Position
: Es la posición de Bookmark
.
Autorización
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
remove()
Borra el Bookmark
. Llamar a este método en un Bookmark
que ya se borró no tiene efecto.
Autorización
Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes ámbitos:
-
https://www.googleapis.com/auth/documents.currentonly
-
https://www.googleapis.com/auth/documents
Salvo que se indique lo contrario, el contenido de esta página está sujeto a la licencia Atribución 4.0 de Creative Commons, y los ejemplos de código están sujetos a la licencia Apache 2.0. Para obtener más información, consulta las políticas del sitio de Google Developers. Java es una marca registrada de Oracle o sus afiliados.
Última actualización: 2025-07-26 (UTC)
[null,null,["Última actualización: 2025-07-26 (UTC)"],[[["\u003cp\u003eA Bookmark object represents a specific location within a Google Doc, allowing you to programmatically interact with it.\u003c/p\u003e\n"],["\u003cp\u003eYou can create a Bookmark using the \u003ccode\u003eaddBookmark()\u003c/code\u003e method of a DocumentTab, inserting it at the current cursor position.\u003c/p\u003e\n"],["\u003cp\u003eBookmarks offer methods to retrieve their unique ID (\u003ccode\u003egetId()\u003c/code\u003e), get their position within the document (\u003ccode\u003egetPosition()\u003c/code\u003e), and remove them (\u003ccode\u003eremove()\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eBookmark positions remain valid even after document modifications, unless the bookmark itself is deleted.\u003c/p\u003e\n"]]],[],null,["# Class Bookmark\n\nBookmark\n\nAn object representing a bookmark.\n\n```javascript\nconst doc = DocumentApp.getActiveDocument();\nconst documentTab = doc.getActiveTab().asDocumentTab();\n\n// Insert a bookmark at the cursor position (in the active tab) and log its ID.\nconst cursor = doc.getCursor();\nconst bookmark = documentTab.addBookmark(cursor);\nLogger.log(bookmark.getId());\n``` \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------|------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [getId()](#getId()) | `String` | Gets the ID of the `Bookmark`. |\n| [getPosition()](#getPosition()) | [Position](/apps-script/reference/document/position) | Gets the [Position](/apps-script/reference/document/position) of the `Bookmark` within the [DocumentTab](/apps-script/reference/document/document-tab). |\n| [remove()](#remove()) | `void` | Deletes the `Bookmark`. |\n\nDetailed documentation\n----------------------\n\n### `get``Id()`\n\nGets the ID of the `Bookmark`. The ID is unique within the [DocumentTab](/apps-script/reference/document/document-tab).\n\n#### Return\n\n\n`String` --- The `Bookmark`'s ID, which is unique within the `Document``Tab`.\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/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n### `get``Position()`\n\nGets the [Position](/apps-script/reference/document/position) of the `Bookmark` within the [DocumentTab](/apps-script/reference/document/document-tab). The `Position` remains accurate so long as the `Bookmark` is not deleted, even if the script\nchanges the document structure.\n\n#### Return\n\n\n[Position](/apps-script/reference/document/position) --- The position of the `Bookmark`.\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/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`\n\n*** ** * ** ***\n\n### `remove()`\n\nDeletes the `Bookmark`. Calling this method on a `Bookmark` that has already been\ndeleted has no effect.\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/documents.currentonly`\n- `https://www.googleapis.com/auth/documents`"]]