Skip to main content
marikaacrobat
New Participant
November 2, 2017
Question

Trouble displaying special characters when importing data to pdf form

  • November 2, 2017
  • 4 replies
  • 6331 views

Hi all, I am trying to import data in order to fill my form fields and am having trouble successfully displaying special characters such as accents and umlauts. The data is saved in a tab-delimited text file which displays these characters just fine, and I even tried saving it as a tab-delimited .txt file with utf-8 encoding, still no luck. My fonts for the fields are set to Helvetica, so I don't see why displaying these characters shouldn't be possible. Any ideas as to what is going wrong? Thanks!!

This topic has been closed for replies.

4 replies

New Participant
September 17, 2019

I write it out in Word, and then copy and paste it into pdf form.

Legend
November 2, 2017

Hmm, that sounds very broken. I don't have a suggestion in that case, sorry.

Legend
November 2, 2017

You mean that if you export then import the same file, it doesn't work? Not entirely clear, sorry, as there are several different suggestions here.

marikaacrobat
New Participant
November 2, 2017

Yeah exactly. I type the characters I want in the fields and they look find and then export and the text file looks fine and then import again and special characters are not displayed correctly.

try67
Community Expert
Community Expert
November 2, 2017

It's possible your text editor re-encodes the file when you save it.

I use Notepad++, where you can explicitly tell it what encoding to use, as well as convert one encoding to another, but I think it's a Windows only application. I'm not sure what the equivalent for Mac would be...

try67
Community Expert
Community Expert
November 2, 2017

How are you importing the data? Do you use a script, or the built-in Import Form Data command?

Can you share a sample PDF and text file?

marikaacrobat
New Participant
November 2, 2017

I've tried with the built in Import Form Data command, and with the following script, which I want to eventually get working so that I can do batch imports:

/* Batch Import and Save */

var fileName = "/Users/rightsup/Documents/newlabels.txt"; // the tab delimited text file containing the data

var outputDir = "/Users/rightsup/Documents/BatchImportTrials/"; 

var err = 0;

var idx = 0;

var str = "";

while (err == 0) {

  err = this.importTextData(fileName, idx);

  if (err == -1)

  app.alert("Error: Cannot Open File");

  else if (err == -2)

  app.alert("Error: Cannot Load Data");

  else if (err == 1)

  app.alert("Warning: User Cancelled File Select");

  else if (err == 2)

  app.alert("Warning: User Cancelled Row Select");

  else if (err == 3)

  app.alert("Warning: Missing Data");

  else if (err == 0)

        str = this.getField("LabelName").value;

        str = str.replace(/[^a-zA-Z0-9]/g, '');

  this.saveAs(outputDir + str + ".pdf");

  idx++;

}

It is a super simple PDF form with just three fields, each set to Helvetica. The .txt file was originally in Excel, and then saved as a tab-delimited file. I also tried saving it from Open Office as a tab-delimited file with uff-8 encoding, which does change the appearance of the special characters on my pdf form, but still not to display the correct ones.

try67
Community Expert
Community Expert
November 2, 2017

Just tried it with a plain-text file and the built-in command. When the file was encoded as UTF-8 it actually didn't work correctly. But when I encoded it as ANSI it did...