Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forge_fdf generates weird characters #9

Open
lc-thomas opened this issue Feb 4, 2015 · 3 comments
Open

forge_fdf generates weird characters #9

lc-thomas opened this issue Feb 4, 2015 · 3 comments

Comments

@lc-thomas
Copy link

Forge_fdf generates weird characters in keys and values of the data I give it.
Since it changes the keys, the output pdf forms aren't modified.

When manually removing these characters, it works very well.

ss 2015-02-04 at 04 22 08

Characters as seen by notepad++ :

ss 2015-02-04 at 04 27 15

@lc-thomas
Copy link
Author

Here's my little (and dirty) workaround :

def smart_encode_str(s):
"""Create a UTF-16 encoded PDF string literal for s."""
try:
utf16 = s.encode('utf_16_be')
except AttributeError: # ints and floats
utf16 = str(s).encode('utf_16_be')
safe = utf16.replace(b'\x00)', b'\x00)').replace(b'\x00(', b'\x00(').replace(b'\x00','')
return b''.join((codecs.BOM_UTF16_BE, safe))[2:]

@mpbunch
Copy link

mpbunch commented Apr 6, 2016

Seems to still be an issue:
screen shot 2016-04-05 at 6 21 56 pm

screen shot 2016-04-05 at 6 30 52 pm

Is there a quick fix for this?

@sontek
Copy link

sontek commented Nov 20, 2017

How does this look now that #16 was merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants