Hey everyone, I’m struggling with a Google Docs issue. I’m trying to connect comments to images, but it’s not working as expected.
Here’s what I’ve found:
- You can get document elements using
DocumentApp.openById(doc_id, folder_id).
- Comments are retrieved through the Drive API with
Comments.list.
- Text comments have a
context entry, but image comments don’t.
I’m working on a tool to convert Google Docs to Markdown, and I need to match comments to images. Without the context for image comments, I’m not sure how to do this.
Does anyone know if it’s possible to store image info in comments? Or should I just assume every image has a comment?
Also, I’m curious about custom comment anchoring systems. Are there any open-source examples out there?
Thanks for any help or ideas!
Having worked extensively with Google Docs API, I can attest to its limitations regarding image comments. One workaround I’ve found effective is to use the document’s structure to your advantage. Try mapping the positions of images and comments within the document’s hierarchy. While not perfect, this method often yields good results for matching comments to images.
Another approach worth considering is to implement a custom naming convention for images. By giving each image a unique identifier in its alt text or caption, you can create a more reliable link between images and their associated comments.
Regarding open-source solutions, while not specific to Google Docs, you might find inspiration in web-based annotation libraries like Annotator.js or Hypothesis. These tools handle similar challenges in web documents and could provide valuable insights for your project.
hey swiftcoder, i feel ya, google docs api sucks sometimes. r u using the anchor prop? maybe try matching images to comment timestamps from documentapp. it might work. good luck bro!
I’ve encountered similar challenges when working with Google Docs API. One approach that worked for me was to use the positioning of images within the document structure. You can iterate through the document elements and track the position of each image. Then, compare this with the location data available for comments (even if it’s not as precise for images).
Another trick I found useful was to add a small, invisible text anchor near each image. This gives you a text-based reference point that can be linked to comments more reliably. It’s not perfect, but it helped in most cases.
As for custom anchoring systems, I haven’t come across any open-source solutions specifically for Google Docs. However, you might want to look into how annotation systems for web-based documents handle this issue. Some of those concepts could potentially be adapted for your use case.