Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

244
Views
How can I set two different paragraphs on the same line in G Docx using Apps Script?

I'm working on a function that generates a Google Docx where it is listed, line by line, every character's name and its lyrics. Every line is made up of two strings: character's name and lyrics. Well, I get my goal using insertTable and formatting it, getting every line as a two column table.

var table = body.insertTable(0, [[pers, text]]);
    var styles = {};
    styles[DocumentApp.Attribute.BORDER_COLOR] = '#ffffff';
    styles[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri';
    styles[DocumentApp.Attribute.FONT_SIZE] = 11;
    table.setAttributes(styles);
This is the result:

docx script

The issue arises because now I need to manipulate this file and I'm struggling to work with so many tables! The question is: is there a way to get the same result without using tables? I tried body.appendParagraph() but I can't figure out how to format the paragraph the same as in the above image.

Can you please help me? ..and.. I do apologize for my bad english!!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Yes. You can format a paragraph and get the same look:

enter image description here

You have to insert a tab symbol after a personage name and set so called 'hanging indentation' for the paragraph.

The code could be something like this:

function setIndents() {
  var doc = DocumentApp.getActiveDocument();
  var indent = 100;
  doc.getBody().getParagraphs().forEach(p => p.setIndentStart(indent));
}

It sets the 'hanging indentation' (100 pt) for all existed paragraphs in current document.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!