-
-
Save strarsis/ef02995ac5cb1ffd77565098bfc6aab4 to your computer and use it in GitHub Desktop.
Extracting a page from an InDesign document (2 different approaches)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doc = app.activeDocument; | |
if(doc.saved == true) | |
{ | |
extract(2); | |
} | |
else | |
{ | |
alert("Save you file."); | |
} | |
function extract(pagePosition){ | |
var docpath = doc.fullName; | |
for(var i=doc.pages.length; i>pagePosition;i--) | |
{ | |
doc.pages[i-1].remove(); | |
} | |
for(var i=pagePosition-1; i>=1;i--) | |
{ | |
doc.pages[i-1].remove(); | |
} | |
var exportdoc = doc.save(File('~/test_extract.indd')); | |
exportdoc.close(SaveOptions.no); | |
app.open(File(docpath)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var doc = app.activeDocument; | |
if(doc.saved == true) | |
{ | |
extract(2); | |
} | |
else | |
{ | |
alert("Save you file."); | |
} | |
function extract(pagePosition){ | |
var exportDoc = app.documents.add(false); | |
var page = doc.pages.item(pagePosition-1) | |
page.duplicate(LocationOptions.BEFORE, exportDoc.pages.firstItem()); | |
exportDoc.pages.lastItem().remove(); | |
exportDoc.save(File('~/test_extract_2.indd')); | |
exportDoc.close(SaveOptions.no); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For extracting all pages into a folder (plus progressbar from https://gist.github.com/kuyseng/2792080):