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

Setting alt text using characters with accents

Explorer ,
Mar 20, 2022 Mar 20, 2022

Copy link to clipboard

Copied

Anyone have any insight on setting an element's Alternate Text field using strings with accents (i.e. à, é, ô)?

 

I'm able to set the value using PDSElementSetAlt, but if the text is using accents (French, Spanish, German) then the accented characters are not showing up correctly.

For example, I have a P struct with "à la maison" as the textual content for the node. I then try to set the Alt Text for that tag using PDSElementSetAlt. The result is that it comes out as "‹ la maison" in the Alternate Text field in the Object Properties panel. The à gets saved as ‹

 

If I print out the string using AVAlertNote, I get the correct "à la maison" printed.

Screen Shot 2022-03-20 at 10.10.36 PM.png
but Alt Text field does not show accented characters.

Screen Shot 2022-03-20 at 10.13.08 PM.png

Here are the 3 lines of code that generate the Alert Note, and set the PDSElement's Alt Text:

sprintf(str,"Setting Alt Text for <%s> element to \"%s\"", nodeName, altText );
AVAlertNote(str);
PDSElementSetAlt( pdsElement, (ASUns8 *)altText, (ASInt32)strlen(altText));

I'm assuming this is because of the "ASUns8*" type for the string? Is there a way to set the text using a different character encoding that supports characters with accents?

TOPICS
Acrobat SDK and JavaScript

Views

448

Translate

Translate

Report

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

correct answers 1 Correct answer

LEGEND , Mar 21, 2022 Mar 21, 2022

PDSElementSetAltASText. 

Votes

Translate

Translate
LEGEND ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

PDSElementSetAltASText. 

Votes

Translate

Translate

Report

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
Explorer ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

LATEST

That was it! Thank you so much! I had been worried about the whole 8-bit vs. 16-bit issues and hadn't even thought to look at ASText (in fact,

PDSElementSetAltASText is not even described in the Core API Reference I keep open – Tech Note #5191, Acrobat 6.0, March 2004). That will teach me to always use the latest...

 

For the record, here is my modified code that appears to work on the dozen or so test cases I've run so far:

sprintf(str,"Setting Alt Text for <%s> element to \"%s\"", nodeName, altText );
AVAlertNote(str);
 
ASText asTextAltText = ASTextFromEncoded(altText, kASRomanScript);
PDSElementSetAltASText( pdsElement, asTextAltText);

 

Votes

Translate

Translate

Report

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