Text from URI value is incorrect.

24 views
Skip to first unread message

Ryan

unread,
May 4, 2016, 4:59:50 PM5/4/16
to PDFTron PDFNet SDK
Question:

We are trying to get the URI string from a Link annotation, but the text is not what we see in Acrobat.

string target = action.GetSDFObj().Get("URI").Value().GetAsPDFText();


How do we get the correct text.

Answer:

Link URI are one of the very few places in the PDF standard, where text is in UTF8 format. Nearly every other instance in a PDF is in one of two other encodings (PDF Doc or UTF16-BE).

To get the correct URI string from this try the following code

byte[] utf8Bytes = action.GetSDFObj().Get("URI").Value().GetBuffer();
string target = System.Text.Encoding.UTF8.GetString(utf8Bytes);

Reply all
Reply to author
Forward
0 new messages