Copy link to clipboard
Copied
I can open a number of indesign files using this code:
var
sourceFiles = File.openDialog ("Show me the source","*.indd", true),
destPage = app.activeDocument.pages[0],
sourceFile, sourceDoc, sourceFrame, outFrame,
mX = 0, mY = 0;
while (sourceFile = sourceFiles.shift()) {
sourceDoc = app.open(sourceFile, false);
sourceFrame = sourceDoc.pages[0].pageItems[0];
outFrame = sourceFrame.duplicate(destPage,[mX,mY]);
// mX += outFrame.geometricBounds[3] - outFrame.geometricBounds[1];
// sourceDoc.close(SaveOptions.NO);
}
now i want fiting every file into a rectangle. For example, I made a rectangle manually:
var
sourceFiles = File.openDialog ("Show me the source","*.indd", true),
destPage = app.activeDocument.pages[0],
sourceFile, sourceDoc, sourceFrame, outFrame,
mX = 0, mY = 0;
while (sourceFile = sourceFiles.shift()) {
sourceDoc = app.open(sourceFile, false);
sourceFrame = sourceDoc.pages[0].pageItems[0];
var myDocument = app.documents.add();
var myRectangle = myDocument.pages.item(0).rectangles.add();
myRectangle.geometricBounds = ["50p", "20p", "40p", "40p"];
myRectangle.fit(sourceFrame.duplicate(destPage,[mX,mY]));
// mX += outFrame.geometricBounds[3] - outFrame.geometricBounds[1];
// sourceDoc.close(SaveOptions.NO);
}
But it's a problem. please help
Copy link to clipboard
Copied
I'll move this to the InDesign Scripting forum for you.
~Barb
Copy link to clipboard
Copied
Hi shahriara7551080 ,
method fit() has one argument, the fit options. You can do:
FitOptions.CONTENT_TO_FRAME
FitOptions.CENTER_CONTENT
FitOptions.PROPORTIONALLY
FitOptions.FRAME_TO_CONTENT
FitOptions.FILL_PROPORTIONALLY
FitOptions.APPLY_FRAME_FITTING_OPTIONS
So you would place a graphic or an InDesign page to a rectangle and use method fit() on the rectangle.
With FitOptions.APPLY_FRAME_FITTING_OPTIONS you could access the frameFittingOptions that could be predefined to e.g. a rectangle, a polygon or an oval: Adobe InDesign CS6 (8.0) Object Model JS: FrameFittingOption
So first do the rectangle, spread.rectangles.add()
then perhaps define frameFittingOptions,
then do rectangle.place() the graphic or the InDesign page
You may then do: rectangle.fit()
Regards,
Uwe
Copy link to clipboard
Copied
pleas give me code .
Copy link to clipboard
Copied
Search the forum for place().
See into that perhaps:
Re: Place InDesign File into another Indesign File
Regards,
Uwe
Copy link to clipboard
Copied
your excut this code :
sourceFiles = File.openDialog ("Show me the source","*.indd", true),
destPage = app.activeDocument.pages[0],
sourceFile, sourceDoc, sourceFrame, outFrame,
mX = 0, mY = 0;
while (sourceFile = sourceFiles.shift()) {
sourceDoc = app.open(sourceFile, false);
sourceFrame = sourceDoc.pages[0].pageItems[0];
outFrame = sourceFrame.duplicate(destPage,[mX,mY]);
// mX += outFrame.geometricBounds[3] - outFrame.geometricBounds[1];
// sourceDoc.close(SaveOptions.NO);
}
Copy link to clipboard
Copied
Believe me, it's better to place an InDesign page ( or an exported PDF/X-4 page ) than to duplicate various elements out of various InDesign documents. You'll need not check for duplicates with paragraph styles, character styles and object styles or differences in basic styles that in the end will do wrong formatting to duplicated items.
Regards,
Uwe
Copy link to clipboard
Copied
And you will be able to fit one placed page or PDF better to a rectangular shape. Perhaps you want to scale them slightly unproportionally. Scaling and positioning formatted page items like text frames and groups of InDesign page items means more hassle. Often text frames in original layouts exceed the bounds of their actual contents and you have to handle that before positioning and scaling. Text wrapped objects will mean hassle too if brought over from other documents. Texts applied to document baseline grids; I could go on and on…
Regards,
Uwe
Copy link to clipboard
Copied
i want fit content indd file (selected ) in rectangel.
Copy link to clipboard
Copied
First you need a file object to place ( an InDesign file ), then you have to decide what page of that file you want to place. And what crop options you do all defined with app.importedPageAttributes. You'd perhaps open the file to place with InDesign before and decide on the contents of the pages there what page to place.
After that you are adding a rectangle to a page with method add() including geometricBounds and perhaps applying an object style where you define fill, stroke and other properties like the frameFittingOptions. Only then you are using place() on the rectangle. You should be able to see what's necessary from my linked post above where I targeted a page instead of a rectangle. Change the code accordingly…
Regards,
Uwe