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

384
Visualizações
Colocar marcos de texto automáticamente uno debajo del otro (JavaScript)

Estoy tratando de automatizar inDesign para crear marcos de texto a partir de un archivo JSON, donde cada registro se colocará en un marco de texto, que se encuentra justo debajo del registro anterior.

 var tweets_json = '[ {"name":"record_1"}, {"name":"record_2"}, ... ]'; // I have not yet figured out how to import external JSON files, so tor testing this is my current way to go var tweets = eval("(" + tweets_json + ")"); for ( var t = 0; t < tweets.length; t++ ) { var newTextFrame = page.textFrames.add(); newTextFrame.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY; var tweet = tweets[ t ]; newTextFrame.parentStory.texts.item(0).applyParagraphStyle(styleContent, true); newTextFrame.geometricBounds = [y1,x1,y2,x2]; // Ignore values newTextFrame.contents = tweet.name; }

Comencé a crear secuencias de comandos en InDesign hace unos días y la documentación es difícil de encontrar la solución que estoy buscando, especialmente con mi conocimiento básico de JavaScript, ¡así que agradezco cualquier ayuda! ¡Gracias!

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Podría ser algo como esto:

 var doc = app.activeDocument; var page = doc.pages[0]; // get JSON data (just as an example) var tweets_json = '[ {"name":"line1 line2"}, {"name":"line3"}, {"name":"line4, line5"}]'; var tweets = eval("(" + tweets_json + ")"); // set geometric bounds for the first text frame var x = 0, y = 0; // coordinates of top a left corner of the text frame var width = 15; // width of the text frame var min_heigth = 20; // minimal heigth of the text frame var bottom = min_heigth; // bottom edge of the text frame var bounds = [y, x, bottom, width]; for (var t = 0; t < tweets.length; t++) { var tweet = tweets[t]; // create the a new text frame and set its geometric bounds var newTextFrame = page.textFrames.add(); newTextFrame.geometricBounds = bounds; // fill the box with a text and apply the style newTextFrame.contents = tweet.name; newTextFrame.parentStory.texts[0].applyParagraphStyle(styleContent, true); // resize the created text box with auto sizing newTextFrame.textFramePreferences.autoSizingReferencePoint = AutoSizingReferenceEnum.TOP_CENTER_POINT; newTextFrame.textFramePreferences.autoSizingType = AutoSizingTypeEnum.HEIGHT_ONLY; // set the new geometric bounds for the next text frame bounds = newTextFrame.geometricBounds; // get the bounds of the created text frame bottom = bounds[2]; // get the new bottom edge bounds[0] = bottom; // set the top edge for the next text frame bounds[2] = bounds[2] + min_heigth; // set the bottom edge for the next text frame }

Resultado:

ingrese la descripción de la imagen aquí

El código un poco detallado, con fines educativos. En realidad, puede ser mucho más corto.

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