How do I add an "ñ" character using the .net SDF API?

31 views
Skip to first unread message

Aaron

unread,
Dec 15, 2014, 6:37:21 PM12/15/14
to pdfne...@googlegroups.com
Q:

I'm trying to add "España" as the location of a digital signature dictionary (following https://www.pdftron.com/pdfnet/samplecode.html#Sig).  But when I just add in the string like sigDict.PutString("Location", "España"), the location appears garbled when I open the document in another PDF viewer.  How can I fix this?

A:

This variant of the PutString API (https://www.pdftron.com/pdfnet/docs/PDFNet/html/M_pdftron_SDF_Obj_PutString_1.htm) performs an implicit encoding conversion.  To avoid the conversion, pass in a byte array instead (https://www.pdftron.com/pdfnet/docs/PDFNet/html/M_pdftron_SDF_Obj_PutString.htm); e.g., by calling sigDict.PutString("Location", Encoding.Default.GetBytes("España")).  Doing so should create the characters correctly.

Aaron

unread,
Dec 15, 2014, 8:10:40 PM12/15/14
to pdfne...@googlegroups.com
Note also --- if you want to store a string using Unicode (i.e. PDF Text Encoding according to PDF spec) you could try
sigDict.PutText("Location", "España");

Reply all
Reply to author
Forward
0 new messages