Copy link to clipboard
Copied
The ExportAllStories.jsx works fine except when Hebrew text (Unicode) is involved: only part of a story is exported, and the Hebrew text is gibberishised. This applies both to when Text Only is exported and when the text is exported as RTF.
Has anyone an idea how this problem could be resolved?
InDesign CC 13.1
macOS High Sierra 10.13.6
Copy link to clipboard
Copied
For Hebrew and MANY other character sets you need to export to Unicode.
You can do this by setting the export preferences. You can see I've done this in the "Switch" for the 2 text formats.
Rtf should be working without change.
//ExportAllStories.jsx
//An InDesign JavaScript
/*
@@@BUILDINFO@@@ "ExportAllStories.jsx" 3.0.0 15 December 2009
Adjusted by Trevor to allow for Unicode
*/
//Exports all stories in an InDesign document in a specified text format.
//
//For more on InDesign/InCopy scripting see the documentation included in the Scripting SDK
//available at http://www.adobe.com/devnet/indesign/sdk.html
//or visit the InDesign Scripting User to User forum at http://www.adobeforums.com
//
main();
function main() {
//Make certain that user interaction (display of dialogs, etc.) is turned on.
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
if (app.documents.length != 0) {
if (app.activeDocument.stories.length != 0) {
myDisplayDialog();
} else {
alert("The document does not contain any text. Please open a document containing text and try again.");
}
} else {
alert("No documents are open. Please open a document and try again.");
}
}
function myDisplayDialog() {
with(myDialog = app.dialogs.add({ name: "ExportAllStories" })) {
//Add a dialog column.
myDialogColumn = dialogColumns.add()
with(myDialogColumn) {
with(borderPanels.add()) {
staticTexts.add({ staticLabel: "Export as:" });
with(myExportFormatButtons = radiobuttonGroups.add()) {
radiobuttonControls.add({ staticLabel: "Text Only", checkedState: true });
radiobuttonControls.add({ staticLabel: "RTF" });
radiobuttonControls.add({ staticLabel: "InDesign Tagged Text" });
}
}
}
myReturn = myDialog.show();
if (myReturn == true) {
//Get the values from the dialog box.
myExportFormat = myExportFormatButtons.selectedButton;
myDialog.destroy;
myFolder = Folder.selectDialog("Choose a Folder");
if ((myFolder != null) && (app.activeDocument.stories.length != 0)) {
myExportAllStories(myExportFormat, myFolder);
}
} else {
myDialog.destroy();
}
}
}
//myExportStories function takes care of exporting the stories.
//myExportFormat is a number from 0-2, where 0 = text only, 1 = rtf, and 3 = tagged text.
//myFolder is a reference to the folder in which you want to save your files.
function myExportAllStories(myExportFormat, myFolder) {
var exportPreference;
for (myCounter = 0; myCounter < app.activeDocument.stories.length; myCounter++) {
myStory = app.activeDocument.stories.item(myCounter);
myID = myStory.id;
switch (myExportFormat) {
case 0:
myFormat = ExportFormat.textType;
myExtension = ".txt"
exportPreference = app.textExportPreferences.properties; // Store old preference value
app.textExportPreferences.characterSet = TextExportCharacterSet.UTF8; // Export to UNICODE
break;
case 1:
myFormat = ExportFormat.RTF;
myExtension = ".rtf"
break;
case 2:
myFormat = ExportFormat.taggedText;
myExtension = ".txt"
exportPreference = app.taggedTextExportPreferences.properties; // Store old preference value
app.taggedTextExportPreferences.characterSet = TagTextExportCharacterSet.UNICODE; // Export to UNICODE
break;
}
myFileName = "StoryID" + myID + myExtension;
myFilePath = myFolder + "/" + myFileName;
myFile = new File(myFilePath);
myStory.exportFile(myFormat, myFile);
switch (myExportFormat) { // Reset to old preference value
case 0:
app.textExportPreferences.properties = exportPreference;
break;
case 2:
app.taggedTextExportPreferences.properties = exportPreference;
break;
}
}
}
Copy link to clipboard
Copied
Thank you, Trevor, for looking into this and for modifying the script. I've run your version of the script but I'm afraid the problem is not resolved: when the RTF file is opened (with MS Word or with LibreOffice Writer), I get the same result as in the screenshot of my original post – only part of the story is exported, and the Hebrew is gibberish.
Something has changed with your version, though: when the TXT file is opened, the result looks perfect, as expected. So this is a great improvement.
An InDesign scripter using Windows tells me the export (with the unmodified script) works fine on his machine. He thinks that MS Word may have some sort of default font encoding that is different per system, but so far I have failed to find out more.
Copy link to clipboard
Copied
The fixes that I applied were only for the 2 text formats.
Rtf doesn't have any export options but shouldn't need. See Unicode Export Preference for RTF
By me it works fine in Hebrew on Mac. I presume you have Hebrew as an installed language?
These issues are normally much less problematic on Mac than Windows.
As it works by me I can't test it out (for free and and not looking for a paid Job now)
Good luck
Copy link to clipboard
Copied
I just wanted to reference this site http://www.pixiesoft.com/flip/
which will convert non encoded gibberish to Hebrew.
The site is in Hebrew and only worth checking out if there's a need
Find more inspiration, events, and resources on the new Adobe Community
Explore Now