Hello my friends!
1. I want to know how can I post graphics into text like in this manual http://www.adobe.com/designcenter/indesign/articles/indcs2at_anchoredob.html
What commands I should to use? Could you give me an example of code?
2. Also, how can I make the text wrapped around the posted graphics?
I use CS3.
Thank you!
Post inline graphics into the text. How?From the Javascript CS3 examples ''Text'' -%26gt; ''AnchoredFrame.jsx'':
//AnchoredFrame.jsx
//An InDesign CS3 JavaScript
//
//Shows how to create an anchored frame.
//
main();
function main(){
?mySetup();
?mySnippet();
}
//Setup Help Text
//Setup help text goes here.
//end setup help text
function mySetup(){
?var myDocument = app.documents.add();
?myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
?myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
?var myPage = myDocument.pages.item(0);
?var myTextFrame = myPage.textFrames.add({geometricBounds:myGetBounds(myDocument, myPage), contents:TextFrameContents.placeholderText});
?myTextFrame.texts.item(0).leftIndent = 72;
?function myGetBounds(myDocument, myPage){
?var myPageWidth = myDocument.documentPreferences.pageWidth;
?var myPageHeight = myDocument.documentPreferences.pageHeight
?if(myPage.side == PageSideOptions.leftHand){
?var myX2 = myPage.marginPreferences.left;
?var myX1 = myPage.marginPreferences.right;
?}
?else{
?var myX1 = myPage.marginPreferences.left;
?var myX2 = myPage.marginPreferences.right;
?}
?var myY1 = myPage.marginPreferences.top;
?var myX2 = myPageWidth - myX2;
?var myY2 = myPageHeight - myPage.marginPreferences.bottom;
?return [myY1, myX1, myY2, myX2];
}
} //end setup
//Snippet Help Text
//Snippet help text goes here.
//end snippet help text
function mySnippet(){
?var myDocument = app.documents.item(0);
?var myPage = myDocument.pages.item(0);
?var myTextFrame = myPage.textFrames.item(0);
?var myInlineFrame = myTextFrame.paragraphs.item(0).insertionPoints.item(0).textFrames.add();
?//Recompose the text to make sure that getting the
?//geometric bounds of the inline graphic will work.
?myTextFrame.texts.item(0).recompose;
?//Get the geometric bounds of the inline frame.
?var myBounds = myInlineFrame.geometricBounds;
?//Set the width and height of the inline frame. In this example, we'll
?//make the frame 24 points tall by 72 points wide.
?myInlineFrame.geometricBounds = [myBounds[0], myBounds[1], myBounds[0]+24, myBounds[1]+72];
?myInlineFrame.contents = ''This is an inline frame.'';
?var myAnchoredFrame = myTextFrame.paragraphs.item(1).insertionPoints.item(0).textFrames.add();
?//Recompose the text to make sure that getting the
?//geometric bounds of the inline graphic will work.
?myTextFrame.texts.item(0).recompose;
?//Get the geometric bounds of the inline frame.
?var myBounds = myAnchoredFrame.geometricBounds;
?//Set the width and height of the inline frame. In this example, we'll
?//make the frame 24 points tall by 72 points wide.
?myAnchoredFrame.geometricBounds = [myBounds[0], myBounds[1], myBounds[0]+24, myBounds[1]+72];
?myAnchoredFrame.contents = ''This is an anchored frame.'';
?with(myAnchoredFrame.anchoredObjectSettings){
?anchoredPosition = AnchorPosition.anchored;
?anchorPoint = AnchorPoint.topLeftAnchor;
?horizontalReferencePoint = AnchoredRelativeTo.anchorLocation;
?horizontalAlignment = HorizontalAlignment.leftAlign;
?anchorXoffset = 72;
?verticalReferencePoint = VerticallyRelativeTo.lineBaseline;
?anchorYoffset = 24;
?anchorSpaceAbove = 24;
?}
} //end snippet
Thanks for your answer, Thomas B. Nielsen!
But seems like your example isn't working properly like in this http://www.adobe.com/designcenter/indesign/articles/indcs2at_anchoredob.html example. I mean, if your text moved, your graphic doesn't moved with it
They should, the first one is placed inline, moving at the basline.
The second is placed relative and will move down if you add lines above it's anchor marker.
The script is for Indesign CS3
Ohh, seems like I've understood. Thank you!
No comments:
Post a Comment