Thanks,

your suggestion seems to work. I'll had some unit tests and get in merge in the 
next couple of days.




From: Luca Bellonda <[email protected]>
Sent: 29 January 2026 13:53
To: [email protected]
Subject: Re: Font names using multi-byte strings

You don't often get email from [email protected]<mailto:[email protected]>. 
Learn why this is important<https://aka.ms/LearnAboutSenderIdentification>
I was able to get the same name and I suggest this method:
1- Translate the string to UTF-8 bytes representation.
2- Get the bytes and encode them instead of characters.

This way the UTF-8 statement should be respected.
In code (beware: not efficient and without error management):

in escapeName of PDFName:

   byte[] characters ;
 // get UTF-8 bytes
   try {
        characters = name.substring((skipFirst ? 1 : 0)).getBytes("UTF-8");
      } catch (UnsupportedEncodingException e) {
          throw new RuntimeException("Invalid Name:"+name);
      }
// encode bytes
        for (int i = 0, c = characters.length; i < c; i++) {
        int ch = (0x00FF&characters[i]);

            if (ch < 33 || ch > 126 || ESCAPED_NAME_CHARS.indexOf(ch) >= 0) {
                sb.append('#');
                toHex(ch, sb);
            } else {
            char cxc = (char)ch ;
                sb.append(cxc);
            }
        }
        return sb.toString();

where toHex() manages an int

Best regards.

Il giorno gio 29 gen 2026 alle ore 01:28 Joao Andre Goncalves 
<[email protected]<mailto:[email protected]>> 
ha scritto:
I tried that earlier but while the PDF is valid, the font name would not match 
the original PDF. I did find the following on the ISO document:
c) Any character that is not a regular character shall be written using its 
2-digit hexadecimal code, preceded by the NUMBER SIGN only.

________________________________
Joao Andre Goncalves
Customer Developer

t | m 07733161880
[email protected]
smartcommunications.com<https://www.smartcommunications.com/>

[https://www.smartcommunications.com/wp-content/uploads/025_Trends2026-450x160_v1.jpg]<https://scale.smartcommunications.com/2026-Trends-White-Paper.html?utm_source=outlook&utm_medium=email&utm_campaign=wc-global-2026-white-paper-2026-trends>

Explore the new era of AI-powered customer engagement. Get your copy of the 
2026 Trends Report 
now.<https://scale.smartcommunications.com/2026-Trends-White-Paper.html?utm_source=outlook&utm_medium=email&utm_campaign=wc-global-2026-white-paper-2026-trends>
 Smart Communications is a trading name of SmartComms SC Limited which is 
registered in England under No. 4303041 whose registered office is at Suite 23, 
LCLB, 95 Mortimer Street, London, W1W 7GB. Please consider the environment 
before printing. The contents of this e-mail are intended for the named 
addressee only. It contains confidential information. Unless you are the named 
addressee or an authorized designee, you may not copy or use it, or disclose it 
to anyone else. If you received it in error please notify us immediately and 
then destroy it. Smart Communications will process your data as described in 
the Smart Communications' External Privacy 
Policy.<https://www.smartcommunications.com/external-privacy-policy/>

Follow us on LinkedIn,<https://www.linkedin.com/company/15166060/admin/> 
YouTube,<https://www.youtube.com/@Smart_Communications/> and 
X.<https://x.com/ccminnovators?lang=en>

Reply via email to