import os, json from google.oauth2.credentials import Credentials from googleapiclient.discovery import build token_path = os.path.expanduser("~/.hermes/profiles/reviewer/google_token.json") with open(token_path, "r") as f: creds_data = json.load(f) creds = Credentials.from_authorized_user_info(creds_data) docs_service = build("docs", "v1", credentials=creds) drive_service = build("drive", "v3", credentials=creds) doc_id = "1sjTe7Im51CY2Tl0SNQrm8xmO7bYweMkq44E0WXaxs1I" doc = docs_service.documents().get(documentId=doc_id).execute() # Print document style / page setup doc_style = doc.get("documentStyle", {}) print("=== Document Style ===") print(f"Page size: {doc_style.get('pageSize')}") print(f"Margin top: {doc_style.get('marginTop')}") print(f"Margin bottom: {doc_style.get('marginBottom')}") print(f"Margin left: {doc_style.get('marginLeft')}") print(f"Margin right: {doc_style.get('marginRight')}") # Print table 1 (header table with photo placeholder) - element [2] body = doc.get("body", {}) content = body.get("content", []) print("\n=== Table at element [2] (1x2, top of doc) ===") el = content[2] table = el["table"] print(f"Table columns: {table.get('columns')}") print(f"Table style: {json.dumps(table.get('tableStyle', {}), indent=2)}") for ri, row in enumerate(table.get("tableRows", [])): for ci, cell in enumerate(row.get("tableCells", [])): cell_style = cell.get("tableCellStyle", {}) content_texts = [] for cel in cell.get("content", []): if "paragraph" in cel: txt = "".join([e.get("textRun", {}).get("content", "") for e in cel["paragraph"]["elements"] if "textRun" in e]) content_texts.append(txt.strip()) print(f" Row {ri}, Col {ci}: text={content_texts}, style={json.dumps(cell_style, indent=4)}") # Print positioned objects print("\n=== Positioned Objects ===") for k, v in doc.get("positionedObjects", {}).items(): props = v.get("positionedObjectProperties", {}) pos = props.get("positioning", {}) obj = props.get("embeddedObject", {}) print(f" ID: {k}") print(f" Layout: {pos.get('layout')}") print(f" LeftOffset: {pos.get('leftOffset')}") print(f" TopOffset: {pos.get('topOffset')}") print(f" Size: {obj.get('size')}") print(f" Margins: top={obj.get('marginTop')} bottom={obj.get('marginBottom')} left={obj.get('marginLeft')} right={obj.get('marginRight')}") print()