PDFBox can't create Form if fields contain non-latin character - coldfusion

I'm trying to create PDF from ColdFusion10 using Apache PDFBox lib.
I have a template PDF file with form fields and filling them out with user data.
But if user inputs non-latin character in any form field I got exception.
For example: Turkish language has character 'İ' (capital i with dot) so I got message:
U+0131 is not available in this font's encoding: WinAnsiEncoding.
Form fıelds in the pdf template use 'Arial' font. Should I use any specific font embed to PDF template to make all characters work? Or it depends on what fonts installed on server (Linux)?
Any help very appreciated!

Related

In Sitecore RTE to disable XHTML

While adding the html in the Rich Text field the html is automatically getting formatted to validate the xhmtl markup on saving the item, how to overcome that issue, how to disable the xhmtl markup validation for the rich text fields in sitecore 9?
Remove the Is Xhtml validator from the four fields in the Rich Text field type validator. It's located here:
/sitecore/system/Settings/Validation Rules/Field Types/Rich Text. If you need this, you may also want to remove the xhtml validator located in the Global Rules item.

Django Admin Area "TextField" replacement. Issue with greek characters

I have replaced the standard Django "TextField" field with TinyMCE, CKEditor and Froala.
When I type a greek word inside the editors (all of them) in the Admin Area, the result in the frontend app is HTML codes.
For example, I type my name Αδριανός and I see <p>Αδριανός</p>
I use Postgres with encoding=UTF8, Collate=English_United States.1253, CType=English_United States.1253
Seems similar to this issue:
Why does TinyMCE in Django admin output HTML tags?
You need to set your default encoding to raw in your TinyMCE configs
TINYMCE_DEFAULT_CONFIG = {
'entity_encoding': 'raw',
. . .
}
For CKEditor, and anything else you just need a way to mark the text entity as safe as you would in any templatel, ie. {{ greek_unicode_entity_string | safe }}
https://www.tiny.cloud/docs-3x/reference/configuration/Configuration3x#entity_encoding/

New Line on Django admin Text Field

I am trying to create a blog o django where the admin posts blogs from the admin site.
I have given a TextField for the content and now want to give a new line.
I have tried using \n but it doesn't help. The output on the main html page is still the same with \n printing in it. I have also tried the tag and allowed tags=True in my models file. Still the same. All the tags are coming as it is on the html page.
My Django admin form submitted:
The result displayed in my public template:
You should use the template filter linebreaks, that will convert the reals \n (that means the newline in the textarea, not the ones you typed using \ then n) into <br />:
{{ post.content|linebreaks }}
Alternatively, you can use linebreaksbr if you don't want to have the surrounding <p> block of course.
After searching the internet and trying different Django Template Filters, I came across one specific filter, SAFE.
For me, LINEBREAKS filter didn't work, as provided by #Maxime above, but safe did.
Use it like this in your html template file.
{{post.content|safe}}
To have a better understanding of SAFE filter, i suggest reading the documentation.
{{post.content|linebreaks}}
This will make the line in the textbox appear as it is without using \n or \.
{{post.content|linebreaksbr}}
Besides the newline function in your CSS Declaration will work too.

how to Write in Django SlugField with hebrew

i need help how to write Hebrew in SlugField in django models
now i can write only English
something like: hello-world
but i what to write in SlugField = "שלום-עולם"
and the url be like:
www.somsite.com/blog/שלום-עולם
10X
The whole idea of the slugfield is that it converts a given string to only url-safe characters. Hebrew is unicode, which means that it generally is unsafe to use in the url. If you want to override this, just use your article title instead of a slugfield.

Uploaded django image ends up with wrong filename

I don't know if this is expected behavior or not, but if I create a project with a single model with an ImageField field and upload a photo with the filename "árvórés", the uploaded file is saved with an incomprehensible filename(ascii, I presume). As a direct result, that photo becomes impossible to retrieve from the site.
Is this normal? If yes, then how to allow those types of filenames?
The issue is that you haven't specified how the POST data should be encoded by the browser, and subsequently you are getting whatever the browser has guessed it should use - usually ISO-8859-1 instead of Unicode (UTF-8).
The HTML 4.01 spec for the FORM element includes the "accept-charset" attribute which allows you to specify your preference for which encoding to POST data with:
accept-charset = charset list [CI]
This attribute specifies the list of
character encodings for input data
that is accepted by the server
processing this form. The value is a
space- and/or comma-delimited list of
charset values. The client must
interpret this list as an exclusive-or
list, i.e., the server is able to
accept any single character encoding
per entity received.
The default value for this attribute
is the reserved string "UNKNOWN". User
agents may interpret this value as the
character encoding that was used to
transmit the document containing this
FORM element.
In other words, if you serve a page encoded in UTF-8, the browser would default to posting requests in UTF-8.
The best fix is to specify the character encoding for all your pages by either including the appropriate encoding in your response headers, or including something like the following in your HTML within the HEAD section:
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
The HTML 4.01 spec has a section on how to specify which character encoding you are serving.
An alternate but lesser fix is to not specify the character encoding anywhere, and instead decode your filename manually assuming the browser is sending in the default encoding of ISO-8859-1:
def upload_file(request):
if request.method == 'POST':
form = UploadFileForm(request.POST, request.FILES)
if form.is_valid():
filename = form.cleaned_data.image.name.decode('iso-8859-1')
...