-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExport InCopy PDFs.jsx
More file actions
148 lines (111 loc) · 4.57 KB
/
Export InCopy PDFs.jsx
File metadata and controls
148 lines (111 loc) · 4.57 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/* --------------------------------------
Export InCopy PDFs
by Aaron Troia (@atroia)
Modified Date: 05/05/25
Description:
Allow Export of both Layout and Story views in InCopy
-------------------------------------- */
var scptName = "Export InCopy PDFs"
var scptVersion = "v1.0.0"
var d = app.activeDocument;
main();
function main () {
try {
if (app.documents.length == 0) {
alert("No documents are open.");
} else {
exportGalley();
exportLayout();
}
} catch (e) {
alert(e.line);
}
}
/* =============================== */
/* ==== PDF Export - Layout ==== */
/* =============================== */
function exportLayout() {
// Switch to view to export
app.activeWindow.viewTab = ViewTabs.LAYOUT_VIEW;
// Acrobat Compatability
app.layoutPDFExportPreferences.acrobatCompatibility = AcrobatCompatibility.ACROBAT_5;
// pageRange = ; // page spread
app.layoutPDFExportPreferences.exportReaderSpreads = false;
//fonts
app.layoutPDFExportPreferences.subsetFontsBelow = 100; // 0-100
//options
app.layoutPDFExportPreferences.includeNotes = true;
app.layoutPDFExportPreferences.pageInformationMarks = true;
app.layoutPDFExportPreferences.optimizePDF = false;
app.layoutPDFExportPreferences.generateThumbnails = false;
app.layoutPDFExportPreferences.interactiveElementsOption = InteractiveElementsOptions.DO_NOT_INCLUDE; // InteractiveElementsOptions.APPEARANCE_ONLY
app.layoutPDFExportPreferences.viewPDF = false;
if (d.saved) {
var thePath = String(d.fullName).replace(/\..+$/, "") + ".pdf";
thePath = String(new File(thePath)); //.saveDlg()
if (thePath == null) {
alert ("You pressed Cancel!");
exit();
}
} else {
thePath = String(new File()); //.saveDlg()
if (thePath == null){
alert ("You pressed Cancel!");
exit();
}
}
thePath = thePath.replace(/\.pdf$/, "");
thePath2 = thePath.replace(/(\d+b|\.pdf$)/, "");
// Here you can set the suffix at the end of the name
FULL = thePath + "_LAYOUT.pdf"; // Print PDF
d.exportFile(ExportFormat.PDF_TYPE, new File(FULL));
}
/* =============================== */
/* ==== PDF Export - Galley ==== */
/* =============================== */
function exportGalley() {
// Switch to Tab to export
app.activeWindow.viewTab = ViewTabs.STORY_VIEW; // ViewTabs.GALLEY_VIEW
// Acrobat Compatability
app.galleyPDFExportPreferences.acrobatCompatibility = AcrobatCompatibility.ACROBAT_5,
//fonts
app.galleyPDFExportPreferences.subsetFontsBelow = 100; // 0-100
app.galleyPDFExportPreferences.appliedFont = "Adobe Garamond Pro";
app.galleyPDFExportPreferences.fontStyle = "Regular";
app.galleyPDFExportPreferences.pointSize = 10;
app.galleyPDFExportPreferences.leading = 100;
//options
app.galleyPDFExportPreferences.includePageInfo = true;
app.galleyPDFExportPreferences.includeStoryInfo = true;
app.galleyPDFExportPreferences.includeAllStories = true; //If true; exports all stories. If false; exports only the current story.
app.galleyPDFExportPreferences.includeParagraphStyles = false;
app.galleyPDFExportPreferences.includeNotes = true;
app.galleyPDFExportPreferences.includeAllNotes = true; // If true; exports both invisible and visible notes. If false; exports only visible notes.
app.galleyPDFExportPreferences.showNotesBackgroundsInColor = true;
app.galleyPDFExportPreferences.includeTrackedChanges = true;
app.galleyPDFExportPreferences.showTrackedChangesBackgroundsInColor = true;
app.galleyPDFExportPreferences.includeAccurateLineEndings = true;
// lineRange = ; // The lines to export. . Can return = LineRange enumerator or String.
app.galleyPDFExportPreferences.includeLineNumbers = false;
// storyColumns = ; // (Fill Page Option) The width of columns to export. Valid only when include accurate line endings is true.
app.galleyPDFExportPreferences.viewPDF = false;
if (d.saved) {
var thePath = String(d.fullName).replace(/\..+$/, "") + ".pdf";
thePath = String(new File(thePath)); //.saveDlg()
if (thePath == null) {
alert ("You pressed Cancel!");
exit();
}
} else {
thePath = String(new File()); //.saveDlg()
if (thePath == null){
alert ("You pressed Cancel!");
exit();
}
}
thePath = thePath.replace(/\.pdf$/, "");
thePath2 = thePath.replace(/(\d+b|\.pdf$)/, "");
// Here you can set the suffix at the end of the name
FULL = thePath + "_STORY.pdf"; // Print PDF
d.exportFile(ExportFormat.PDF_TYPE, new File(FULL));
}