Possible encoding problem in exportAsXFDFStr

PDF-XChange Viewer SDK for Developer's
(ActiveX and Simple DLL Versions)

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Post Reply
prosozial_schmitt
User
Posts: 49
Joined: Tue Dec 28, 2004 9:49 am

Possible encoding problem in exportAsXFDFStr

Post by prosozial_schmitt »

Hello,

i want to use exportAsXFDFStr to export fieldvalues into a string. The returned string differs from the result of exportAsXFDF (into file). It seems, that the encoding of the result of exportAsXFDFStr is wrong?
See screenshot.

How can I use exportAsXFDFStr to get the fieldvalues as string without encoding-problem?
Which encoding do you use internaly in your javascript implementation?

Greetings
Hans-Peter
Attachments
Encoding problem.zip
Screenshot
(455.19 KiB) Downloaded 150 times
User avatar
Lzcat - Tracker Supp
Site Admin
Posts: 677
Joined: Thu Jun 28, 2007 8:42 am

Re: Possible encoding problem in exportAsXFDFStr

Post by Lzcat - Tracker Supp »

Hi Hans-Peter.
If you take a closer look at your screen-shot you will see an answer to your question it the first lines of returned string - encoding is UTF-8. So to get correct text you should convert it to other encoding you need (interpreting UTF-8 text as ASCII fails when non-ascii characters are used).
HTH.
Victor
Tracker Software
Project manager

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
prosozial_schmitt
User
Posts: 49
Joined: Tue Dec 28, 2004 9:49 am

Re: Possible encoding problem in exportAsXFDFStr

Post by prosozial_schmitt »

Hello Lzcat,

i've tried this before posting in your blog - but this is not the problem.
The encoding of the returned string from exportAsXFDFStr is not UTF-8. The XML has only the information "UTF-8" in it's header. I've checked this with your sample application "VB.NET Full Demo".
Even this sample shows a not correct decoded JScript-result.

After researching and testing:
I seems that your .NET COM-Wrapper of the exportAsXFDFStr-implementation returns a "ISO-Latin1" encoded string. After reading "Adobe XML Forms Data Format Specification" in section "String encoding conventions": "Use ISO-Latin1 as the assumed encoding of the bytes in the PDF. For example, for the link annotation,
this applies to the Named Destination name and the file OriginalName.".

I've changed my code to:

Dim xfdfBinary = System.Text.Encoding.GetEncoding("iso-8859-1").GetBytes(jsResult)
return System.Text.Encoding.UTF8.GetString(xfdfBinary)

For this case, it seems to solve the problem.

But I have not expected to get an incorrect decoded string from your .NET COM-Wrapper methods of the RunJavaScript method only(?) in case of the "exportAsXFDFStr" javascript-implementation. A COM-Wrapper which converts a bstr in a .NET string should deliver a correct displayable string.
On the other way: if a not correct decoded .NET String is a "desired behaviour", a hint in your documentation would be nice.

Thank you for your answer
Hans-Peter
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Possible encoding problem in exportAsXFDFStr

Post by Ivan - Tracker Software »

Can you send us your PDF with problematic form field value?
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
prosozial_schmitt
User
Posts: 49
Joined: Tue Dec 28, 2004 9:49 am

Re: Possible encoding problem in exportAsXFDFStr

Post by prosozial_schmitt »

Hello Ivan,

I've attached the file.

Greetings
Hans-Peter
Attachments
PDF Formular Antrag auf ALG II.zip
(280.14 KiB) Downloaded 140 times
User avatar
Ivan - Tracker Software
Site Admin
Posts: 3549
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: Possible encoding problem in exportAsXFDFStr

Post by Ivan - Tracker Software »

Thanks for the file. The issue is fixed now, and the fix will be available in next build of the Editor. Unfortunately, I cannot say exact date when this build will be available yet.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.
Post Reply