google-drive-apiexportcomments

Export Google Doc without comments


I am using the google drive api v3 files.export method to get the text/html version of a google doc. I noticed that all the currently open comments in the doc also show up in the content as footnotes. I was wondering if there is any way to export the content of the doc without exporting the open comments. I can’t seem to find any options for files.export that would disable comments. Thanks in advance for any help.


Solution

  • Unfortunately, when Google Docs are exported, there are no methods for directly removing comments. So how about this workaround?

    1. Retrieve all comment IDs from the Google Doc using drive.comments.list.
    2. Remove all comments on the Google Doc using drive.comments.delete.
    3. Export the Google Doc as HTML using drive.files.export.

    Note :

    References :

    If I misunderstand your question, I'm sorry.

    Edit :

    When you will modify HTML using regex, how about a following regex?

    <sup><a href="#cmnt\w.+?<\/a><\/sup>|<div style=\"border:1px solid black;margin:5px\">[\w\W]+<\/div>
    

    When above regex is used for the exported Google Doc, the result is as follows.

    From :

    enter image description here

    To :

    enter image description here

    If this was not useful for you, I'm sorry.