Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Language Database for Acrobat Pro

New Here ,
Aug 04, 2024 Aug 04, 2024

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?

 

TOPICS
Create PDFs , Edit and convert PDFs , How to , JavaScript , PDF , PDF forms
850
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 04, 2024 Aug 04, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 04, 2024 Aug 04, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 04, 2024 Aug 04, 2024

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".

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 05, 2024 Aug 05, 2024

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 05, 2024 Aug 05, 2024
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines