I'm making a script that automatically generates PDF files via Google Docs. Part of that is text in the margin of each page that is unique to each document. Manually, that can be done by adding a drawing in each page and editing the contents of the drawing.
Unfortunately, I can't seem to find a way to access those drawings in code so the workflow has to be different. I've looked into the image classes of Google Docs (InlineImage
and PositionedImage
) but those don't work either because (1) the image isn't inline and (2) the contents and pages of each file vary a lot so I can't find a suitable anchor element for PositionedImage
.
I've also tried exploring the idea of generating an empty page with the filled-in margin and using that as a page background but Google Docs doesn't seem to support background images. Also thought about using watermarks but I can't seem to find documentation of it on Apps Script.
Any possible solution to this problem is appreciated, so long as the result is a PDF file that has the text in the margin. Preferably, the text on the document is still highlightable text, but the margin ones can be an image if needed.
Screenshot below of what an empty page would look like.