Automated rotating and placing image and text on a page in InDesign

一世执手 提交于 2019-12-25 06:47:07

问题


I have been tasked with taking a set of product images and text and placing them in a booklet (with facing pages) and putting the product description next to the image.

Most images are landscape orientation whilst the book is portrait, and so they need to be rotated. For the images that have to be rotated, I'm placing the text in a textframe, fitting the frame to the content, then calculating the max image size, to then resize and then placing the image and rotating 90 / 270 degrees depending on whether the page is a left-hand or right-hand side page. This is rather long-winded for a rather simple operation of placing the image and text and rotating.

Is there a more automated method in InDesign, where it will rotate the image and textframe correctly depending on whether the page is left-hand or right-hand?


回答1:


Here is a javascript script that you can call:

const cs = CoordinateSpaces.pasteboardCoordinates,
ap = AnchorPoint.centerAnchor;

var main = function() {
	var doc = app.properties.activeDocument,
	gfxs, gfx, pg, par,
	mx90 = app.transformationMatrices.add({counterclockwiseRotationAngle:90}),
	mx270 = app.transformationMatrices.add({counterclockwiseRotationAngle:270});
	
	if ( !doc ) return;
	
	gfxs = doc.allGraphics;
	
	while ( gfx = gfxs.pop() ) {
		par = gfx.parent;
		par.locked = false;
		pg = par.parentPage;
		
		if  (pg instanceof Page) {
			par.transform ( cs, ap, pg.side==PageSideOptions.RIGHT_HAND? mx270 : mx90 );
		}

	}
}

var u;
app.doScript ( "main();", u, u, UndoModes.ENTIRE_SCRIPT );

For a real time execution you need to use it in combination with an event listener.



来源:https://stackoverflow.com/questions/37558057/automated-rotating-and-placing-image-and-text-on-a-page-in-indesign

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!