Acrobat Javascript roundtrip to external editor replacing non-English characters
I'm building an interactive PDF with JS in a project which requires language localization, so there's a bunch of strings in the JS with non-english characters.
Acrobat seems to support this nicely until you get an external JS editor involved, in which case Acrobat corrupts the code, replacing the non-english characters with garbage (see the proof of concept example below).
Why use the external editor at all? For small projects, you can paste your code from your preferred editor into Acrobat's bare bones internal JS editor, but once your code exceeds a certain character limit, Acrobat requires you to use an external editor exclusively. I haven't had any problems with this configuration when the code and strings made up of english characters.
If anybody has any ideas on how I might fix this, I'd be very appreciative.
Code maintained entirely within Acrobat:
/*---------- Begin PDF Document Script ----------*/
function Open()
{}
/*---------- Begin VARIABLE declaration ----------*/
// Field to variable connections
var dtlanguage = this.getField("dtlanguage");
var gVis = {
gVisSetLanguage : function () {
if (event.target.name == 'English') {
dtlanguage.value = 'Hello there.';
dtlanguage.textFont = "BentonSans-Light";
}
else if (event.target.name == 'Spanish') {
dtlanguage.value = '¡Holå!';
dtlanguage.textFont = "BentonSans-Light";
}
else if (event.target.name == 'Japanese') {
dtlanguage.value = '資かけっ入迫';
dtlanguage.textFont = "HiraKakuPro-W3";
}
}
}
Code saved through Acrobat's internal editor, then opened through an external editor:
/*---------- Begin PDF Document Script ----------*/
function Open()
{}
/*---------- Begin VARIABLE declaration ----------*/
// Field to variable connections
var dtlanguage = this.getField("dtlanguage");
var gVis = {
gVisSetLanguage : function () {
if (event.target.name == 'English') {
dtlanguage.value = 'Hello there.';
dtlanguage.textFont = "BentonSans-Light";
}
else if (event.target.name == 'Spanish') {
dtlanguage.value = '�Hol�!'; // <--------- HERE
dtlanguage.textFont = "BentonSans-Light";
}
else if (event.target.name == 'Japanese') {
dtlanguage.value = '......'; // <-------- HERE
dtlanguage.textFont = "HiraKakuPro-W3";
}
}
}
