-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__transfer_text_format.jsx
More file actions
53 lines (42 loc) · 1.51 KB
/
__transfer_text_format.jsx
File metadata and controls
53 lines (42 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
main();
// general variables
var myLayer;
var myDocument;
var myPageWidth;
var myPageHeight;
var myPage;
var myMargins;
var marginWidth;
var marginHeight;
function main() {
myDocument = app.activeDocument;
myPageWidth = myDocument.documentPreferences.pageWidth;
myPageHeight = myDocument.documentPreferences.pageHeight;
myPage = myDocument.layoutWindows[0].activePage;
myMargins = myPage.marginPreferences;
marginWidth = myPageWidth - (myMargins.left + myMargins.right);
marginHeight = myPageHeight - (myMargins.top + myMargins.bottom);
if (myDocument.selection !== undefined && app.selection[0] !== undefined) {
var frame = app.selection[0];
var content = frame.contents;
var texts = frame.texts[0];
//alert(texts.appliedParagraphStyle.name);
createTextFrame(content, texts.appliedParagraphStyle, 50, 50, 100, 100);
}
else {
alert("No valid selection, please select a text frame");
}
}
// Function to create a text frame :
// takes a string, creates a frame of text with this string
function createTextFrame(string, format, y1, x1, y2, x2) {
//$.writeln(myDocument);
var myFrame = myDocument.textFrames.add(myLayer, undefined, undefined, {
geometricBounds: [y1, x1, y2, x2],
contents: string
});
myFrame.texts[0].appliedParagraphStyle = format;
// fit frame to content
//myFrame.fit(FitOptions.FRAME_TO_CONTENT);
//myFrame.resolve(AnchorPoint.CENTER_ANCHOR, CoordinateSpaces.INNER_COORDINATES);
}