Copy link to clipboard
Copied
Hello,
I have pdf forms that the user can change the form's language using a dropdown menu. Right now I have only two languages so it works properly. However, if I want to add more languages, the form will be too slow since I manually add the translations to the script. Is there any way to get it from a database? Do you have any recommendations?
Copy link to clipboard
Copied
How are you currently doing it? Are you using layers?
In order to use a database all the contents of the file must be something that can be edited, like form fields. That can be a LOT of work setting it all up, just to avoid having a somewhat large file size. I would not recommend you try doing that.
Copy link to clipboard
Copied
I am using Javascript to change the text boxes when the user selects another language from the dropdown menu. I manually write translations to the Java script. I don't use layers at all.
Copy link to clipboard
Copied
In that case, yes, you can do it. You can use a tab-delimited text file for the database with the names of the fields in the columns and each row matching a different language. Then attach that file to your PDF, read and parse its data when the file is opened, and change the values of the fields when the user switches between languages using the data-model you've created.
This is a bit complex, though. If you're a novice with Acrobat JS it might be a bit too much for you to be able to handle. If you're interested in hiring a professional to create it for you, feel free to contact me privately by clicking my user-name and then on "Send a Message".
Copy link to clipboard
Copied
Thank you for reply. Right now I am trying to implement it by myself if I understand how to convert binary to string. Could you help me a bit?
var xmlFileName = "translations.xml";
var xmlFileData;
var embeddedFile = this.getDataObject(xmlFileName);
xmlFileData = embeddedFile.data;
and after this, xml data is empty.
Copy link to clipboard
Copied
XML files are not binary, they are plain-text files. All you need to do is read the contents of the file, using getDataObjectContents, and then convert that stream into a string. There are examples of this in the Acrobat JS API Reference.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more