Download Xtags User's Guide
Transcript
Chapter 11 Automating Document Building
// the automatic text flow. (we could also use a ¶
// pre-named text box). Set that as the target location.¶
app.select(
doc.textFrames[0].insertionPoints[0],
SelectionOptions.replaceWith);¶
// Attempt the import, catching any resulting error.¶
try {¶
// Insert the file with Xtags using sensible settings¶
doc.getTextWithXtags(
xtagsfile, true, true, false,
XtagsTextEncoding.winlatin);¶
}¶
catch(msg) {¶
// If there was an error, display the error message¶
alert("Get text with Xtags failed: " + msg);¶
}¶
// Additional actions, such as saving the document, could¶
// go here.¶
VB Script (InDesign/Windows only)
set fileDlg = CreateObject("UserAccounts.CommonDialog")¶
' Prompt for the InDesign template file.¶
set appcs3 = CreateObject("InDesign.Application.CS3")¶
if fileDlg.ShowOpen = 0 then MsgBox(
"No file selected:
quitting.")¶
templatefile = fileDlg.FileName¶
' Prompt for the Xtags file to be imported.¶
if fileDlg.ShowOpen = 0 then MsgBox(
"No file selected:
quitting.")¶
xtagsfile = fileDlg.FileName¶
set doc = appcs3.open(templatefile)¶
' The script assumes that the first box on the page is¶
' the automatic text flow. (we could also use a pre-named¶
' text box). Set that as the target location.¶
appcs3.select (doc.textFrames(1).insertionPoints(1))¶
' Attempt the import. Insert the file with Xtags, using¶
' sensible settings¶
appcs3.ActiveDocument.getTextWithXtags xtagsfile, true,
true, false, idutf8¶
' Additional actions, such as saving the document, could¶
' go here.¶
Xtags User’s Guide 69