Skip to main content
mathatak
Participant
January 9, 2020
Question

How can i adjust all the content to the block In a table ?

  • January 9, 2020
  • 2 replies
  • 530 views

Bonjour,
Je souhaite dans la première colonne d'un tableau, sélectionner toutes les images pour les mettre soit 100% ou les adaptater au bloc avec la fonction "ajuster le contenu au bloc". Mais comment faire pour toutes les sélectionner car on ne peut les sélectionner que une par une. Esiste t-il un script? Merci de votre aide

 

Hello,
I want in the first column of a table, select all the images to put them either 100% or adapt them to the block with the function "adjust the content to the block". But how to select them all because you can only select them one by one. Is there a script? Thank you for your help

 

 

This topic has been closed for replies.

2 replies

Community Expert
January 9, 2020

Well, then the next question is:

Did you ever try scripting InDesign with ExtendScript ( JavaScript ) ?

Or do you have at least some experience in JavaScript?

 

The code below is written in ExtendScript ( JavaScript ) and will give you an array of all graphics that are placed directly to graphic cells in the first column of a selected table. To run the code you have to save it as plain text file with a *.jsx suffix and place the file into the folder that you can access from InDesign's Scripts Panel User folder.

 

And you have to select the table in your document.

 

To understand the code will be the precondition to go from there. So also read all my comments in the code below.

It's a good starting point to get access to all the graphics ( or images ) you want to work with:

 

/**
* @@@BUILDINFO@@@ Get-AllGraphics-in-GraphicCells-of-FirstColumnOfTable.jsx !Version! Thu Jan 09 2020 14:20:52 GMT+0100
*/

//DESCRIPTION:Do something to all graphics that are placed in graphic cells in the first column of a selected table

/*
	
	Script by Uwe Laubender
	Posted at Adobe InDesign Forum in thread:
	
	How can i adjust all the content to the block In a table ?
	mathatak
	https://community.adobe.com/t5/indesign/how-can-i-adjust-all-the-content-to-the-block-in-a-table/td-p/10845008
	
	To select a table:
	Select a cell and do Selct All
	
	To select a graphic cell select the container frame in the cell and type: Esc
	To select a text cell select some text in the cell and type: Esc
	
*/

( function()
{
	// If no document is open, do nothing:
	if( app.documents.length == 0 ){ return };

	// If no table is selected, do nothing:
	if( app.selection.length != 1 ){ return };
	if( app.selection[0].constructor.name != "Table" ){ return };
	
	// No graphic cells available with your version of InDesign? Do nothing:
	if( !app.selection[0].cells[0].hasOwnProperty("cellType") ){ return };


	var myTable = app.selection[0];

	var myGraphicsArray = myTable.columns[0].cells.everyItem().allGraphics ;

	// IMPORTANT: Flatten array of arrays to get an array of graphics and images:
	myGraphicsArray = [].concat.apply( [] , myGraphicsArray );
	
	// Now loop the array to filter the right graphics:

	for( var n=0; n<myGraphicsArray.length; n++ )
	{
		var graphic = myGraphicsArray[n];
		var graphicContainer = graphic.parent ;
		var outerContainer = graphicContainer.parent ;
		
		// Check if the graphic or image is placed directly in a graphic cell:
		// That will EXCLUDE graphics that are grouped and pasted inside the graphic frame of a graphic cell.
		if
		( 
			outerContainer.constructor.name == "Cell" && 
			outerContainer.cellType == CellTypeEnum.GRAPHIC_TYPE_CELL 
		)
		{
			// NOW DO SOMETHING TO:
			
			// The graphic container holding the image
			// The graphic itself
			// The outer container, which is the graphic cell
			
			// EG FIT THE GRAPHIC TO ITS CONTAINER LIKE SO:
			
			// The graphic or image will not be cropped:
			graphicContainer.fit( FitOptions.PROPORTIONALLY ); 
			
		};
	};

}() )

 

For ExtendScript development on Windows use the ExtendScript Toolkit App, short the ESTK.

With the latest Mac OS X the ESTK is not available anymore. Even with previous versions of OS X there is a serious bug in the ESTK so it's better to look after a substitution for the ESTK like the Adobe ExtendScript Debugger for Visual Studio Code on Mac OS X.

 

Also visit the description of the Document Object Model for ExtendScript with InDesign compiled by Gregor Fellenz:

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html

 

Regards,
Uwe Laubender

( ACP )

Community Expert
January 9, 2020

Hm. A tiny step in the right direction would be to replace the placed images showing import options so that you can apply a clipping path with threshold. And then fit the frame with the result.

 

So you could try the following.

Before the code line with graphicContainer.fit() insert that code and run the script:

 

		try
		{	
			graphic.place( graphic.itemLink.filePath , true );
		}
		catch(e){ /* $.writeln(e.message) */ };

 

You will be prompted with the import options for every placed graphic that was found in the first column of your table.

 

Best,
Uwe Laubender

( ACP )

mathatak
mathatakAuthor
Participant
January 9, 2020

I can't find graphiccontanier.fit !

Community Expert
January 9, 2020

What's your version of InDesign?

Did you consider using graphic cells for the cells with the images?

Or even better: Are all of your images placed in graphic cells?

 

How do you decide if an image should be scaled to 100% ?

And if the image is scaled, is it ok to crop the graphic because the height or width of the cell cannot show the whole graphic?

 

Regards,
Uwe Laubender

( ACP )

mathatak
mathatakAuthor
Participant
January 9, 2020

- ID v15.0.1
- My images are in graphic cells
- I want to crop all my images according to the content (clipping path with threshold: 25 tolerance: 0) by selecting several cells.