Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

234
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda