Copy link to clipboard
Copied
I need to do a book catalog redesign, all the entries from the previous editions will be in the new edition.
I've designed a new layout, and now I have to copy a lot of text from the previous edition to the new structure, as in the image below
I have already made a script to find text by paragraph style, create text frames for the new layout and move the found text to its place on the new frames. It already helps a lot, but I wanted to go one step further and add other elements to the output of my script. These elements, however, are not simple text frames. They include text frames and vector shapes. Something I don't know how to include in the page by script. (The elements I'm talking about are the orange ones in the image)
So, my question is: Is there a way to store indesign elements somewhere I can retrieve them from, edit them and place them in the page programatically?
Here's my script. (Note how i have hardcoded the frames ObjectStyles and GeometricBounds)
function rediagramar() {
function separarSelecao(selecao){
for (var i = selecao.length - 1; i >= 0; i--){
// para cada item da seleção
if (selecao.constructor.name == "TextFrame"){
// se o item da seleção for uma caixa de texto
var paragraphs = selecao.parentStory.paragraphs;
for (var j = paragraphs.count() - 1; j >= 0; j--){
// para cada parágrafo da caixa de texto
paragraph = paragraphs.item(j);
if (paragraph.appliedParagraphStyle.name == "APIS-readers-livros-titulo") {
//conteudo.titulo = paragraph;
paragraph.duplicate(LocationOptions.after, frame_a.insertionPoints[0] );
};
if (paragraph.appliedParagraphStyle.name == "APIS-readers-livros-autor") {
//conteudo.autor = paragraph;
a = paragraph.duplicate(LocationOptions.after, frame_a.insertionPoints[0] );
//Dirty fix: Limpar a quebra de parágrafo depois do autor para que o frame dê o fit corretamente
app.findGrepPreferences.findWhat = "\r$";
app.changeGrepPreferences.changeTo = "";
a.changeGrep();
};
if (paragraph.appliedParagraphStyle.name == "APIS-readers-livros-pagina-genero") {
//conteudo.genero = paragraph;
paragraph.duplicate(LocationOptions.after, frame_d.insertionPoints[0] );
};
if (paragraph.appliedParagraphStyle.name == "APIS-readers-livros-texto") {
//conteudo.texto.push(paragraph);
paragraph.duplicate(LocationOptions.after, frame_c.insertionPoints[0] );
};
}
};
}
}
function criarTextFrame (a, b, c, d, style) {
var newTextFrame = page.textFrames.add();
if(!doc.objectStyles.item(style).isValid) {doc.objectStyles.add({name:style});}
newTextFrame.properties = {
geometricBounds: [a,b,c,d],
appliedObjectStyle: doc.objectStyles.item(style)
};
return newTextFrame
}
frame_a = criarTextFrame(4.8, 7.0, 21.1,76.8, "APIS-readers-titulo");
frame_b = criarTextFrame(21.1, 0, 63.4, 28.0, "APIS-readers-capa");
frame_c = criarTextFrame(21.1, 28.0, 74.1, 76.8, "APIS-readers-sinopse");
frame_d = criarTextFrame(63.4,7.0,74.1, 28.0, "APIS-readers-genero");
separarSelecao(app.selection);
app.activeWindow.activePage.groups.add([frame_a,frame_b,frame_c, frame_d]);
app.activeWindow.activePage.groups.item(-1).select();
}
… So, my question is: Is there a way to store indesign elements somewhere I can retrieve them from, edit them and place them in the page programatically? …
Hi,
did you consider using IDMS snippet files?
You could export and place them on a page.
Or InDesign library files where you can store snippets (assets) and place them with placeAsset() as well?
See into Asset, Assets, Library and Libraries:
Adobe InDesign CS6 (8.0) Object Model JS: Table of Contents, Libraries Suite
...Copy link to clipboard
Copied
… So, my question is: Is there a way to store indesign elements somewhere I can retrieve them from, edit them and place them in the page programatically? …
Hi,
did you consider using IDMS snippet files?
You could export and place them on a page.
Or InDesign library files where you can store snippets (assets) and place them with placeAsset() as well?
See into Asset, Assets, Library and Libraries:
Adobe InDesign CS6 (8.0) Object Model JS: Table of Contents, Libraries Suite
Adobe InDesign CS6 (8.0) Object Model JS: Library
Adobe InDesign CS6 (8.0) Object Model JS: Asset
For exporting snippets to files use: ExportFormat.INDESIGN_SNIPPET:
You could export e.g. grouped objects as snippet:
Adobe InDesign CS6 (8.0) Object Model JS: Group
And place them on a page:
Adobe InDesign CS6 (8.0) Object Model JS: Page
Regards,
Uwe
Copy link to clipboard
Copied
Nice! It works!
With snippets I can avoid the step of hardcoding every text frame as I was doing.
Thanks!