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
Possible encoding problem in exportAsXFDFStr
Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
-
- User
- Posts: 49
- Joined: Tue Dec 28, 2004 9:49 am
Possible encoding problem in exportAsXFDFStr
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 677
- Joined: Thu Jun 28, 2007 8:42 am
Re: Possible encoding problem in exportAsXFDFStr
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.
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.
Tracker Software
Project manager
Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
-
- User
- Posts: 49
- Joined: Tue Dec 28, 2004 9:49 am
Re: Possible encoding problem in exportAsXFDFStr
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
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
-
- Site Admin
- Posts: 3556
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
Re: Possible encoding problem in exportAsXFDFStr
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.
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.
-
- User
- Posts: 49
- Joined: Tue Dec 28, 2004 9:49 am
Re: Possible encoding problem in exportAsXFDFStr
Hello Ivan,
I've attached the file.
Greetings
Hans-Peter
I've attached the file.
Greetings
Hans-Peter
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 3556
- Joined: Thu Jul 08, 2004 10:36 pm
- Location: Vancouver Island - Canada
Re: Possible encoding problem in exportAsXFDFStr
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.
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.