0

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.

Empty document screenshot

Rubén
  • 34,714
  • 9
  • 70
  • 166
Ulyzses
  • 83
  • 2
  • 13
  • 1
    The question needs more focus, but before investing too much time, please be aware that the Docs Service (Document App) / Advance Docs Service aren't able to handle all the document attributes that the user interface can do. – Rubén Oct 03 '22 at 15:24
  • Related: https://stackoverflow.com/q/20274302/1595451 – Rubén Oct 04 '22 at 02:41
  • 2
    As mentioned in the above comment, instead of rotating the contract, as an alternative, have you also considered using a header or footer? You can access that section through Apps Script. – Lorena Gomez Oct 04 '22 at 17:29

1 Answers1

-1
  1. Open a Google Doc.
  2. Select a section of your content.
  3. At the top, click Insert and then Break.
  4. Choose a break type.
  5. ​To start on a new page, click Page break.
  6. To start a new section on the same page, click Section break (continuous).

​Tip: You can change the margins or page numbers of different section breaks.